From dca12522a9f9e37f126ab925fd385c807ab4f84e Mon Sep 17 00:00:00 2001 From: Nat Jeffries Date: Thu, 24 Sep 2020 09:35:29 -0700 Subject: [PATCH] Add static cast to avoid implicit double promotion. (#6132) Add static cast from float to double in flexbuffers.h to avoid implicit double promotion error. This error is surfacing during the tensorflow lite for microcontrollers build since we enabled -Werror and -Wdouble-promotion. --- include/flatbuffers/flexbuffers.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h index 7e55a7f60..a45d14b12 100644 --- a/include/flatbuffers/flexbuffers.h +++ b/include/flatbuffers/flexbuffers.h @@ -1417,7 +1417,10 @@ class Builder FLATBUFFERS_FINAL_CLASS { Value(uint64_t u, Type t, BitWidth bw) : u_(u), type_(t), min_bit_width_(bw) {} - Value(float f) : f_(f), type_(FBT_FLOAT), min_bit_width_(BIT_WIDTH_32) {} + Value(float f) + : f_(static_cast(f)), + type_(FBT_FLOAT), + min_bit_width_(BIT_WIDTH_32) {} Value(double f) : f_(f), type_(FBT_FLOAT), min_bit_width_(WidthF(f)) {} uint8_t StoredPackedType(BitWidth parent_bit_width_ = BIT_WIDTH_8) const {