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.
This commit is contained in:
Nat Jeffries
2020-09-24 09:35:29 -07:00
committed by GitHub
parent e0bbaa6f9c
commit dca12522a9

View File

@@ -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<double>(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 {