From 1b9d1b01104b42972421aa1cb7d159b10d1ca7b8 Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Mon, 25 Feb 2019 21:45:11 +0100 Subject: [PATCH] IterateValue: Use ReadScalar instead of unportable reinterpret_casts (#5209) This fixes the testcase MiniReflectFlatBuffersTest. --- include/flatbuffers/minireflect.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/flatbuffers/minireflect.h b/include/flatbuffers/minireflect.h index e3def08df..fc0cc43cf 100644 --- a/include/flatbuffers/minireflect.h +++ b/include/flatbuffers/minireflect.h @@ -122,58 +122,58 @@ inline void IterateValue(ElementaryType type, const uint8_t *val, soffset_t vector_index, IterationVisitor *visitor) { switch (type) { case ET_UTYPE: { - auto tval = *reinterpret_cast(val); + auto tval = ReadScalar(val); visitor->UType(tval, EnumName(tval, type_table)); break; } case ET_BOOL: { - visitor->Bool(*reinterpret_cast(val) != 0); + visitor->Bool(ReadScalar(val) != 0); break; } case ET_CHAR: { - auto tval = *reinterpret_cast(val); + auto tval = ReadScalar(val); visitor->Char(tval, EnumName(tval, type_table)); break; } case ET_UCHAR: { - auto tval = *reinterpret_cast(val); + auto tval = ReadScalar(val); visitor->UChar(tval, EnumName(tval, type_table)); break; } case ET_SHORT: { - auto tval = *reinterpret_cast(val); + auto tval = ReadScalar(val); visitor->Short(tval, EnumName(tval, type_table)); break; } case ET_USHORT: { - auto tval = *reinterpret_cast(val); + auto tval = ReadScalar(val); visitor->UShort(tval, EnumName(tval, type_table)); break; } case ET_INT: { - auto tval = *reinterpret_cast(val); + auto tval = ReadScalar(val); visitor->Int(tval, EnumName(tval, type_table)); break; } case ET_UINT: { - auto tval = *reinterpret_cast(val); + auto tval = ReadScalar(val); visitor->UInt(tval, EnumName(tval, type_table)); break; } case ET_LONG: { - visitor->Long(*reinterpret_cast(val)); + visitor->Long(ReadScalar(val)); break; } case ET_ULONG: { - visitor->ULong(*reinterpret_cast(val)); + visitor->ULong(ReadScalar(val)); break; } case ET_FLOAT: { - visitor->Float(*reinterpret_cast(val)); + visitor->Float(ReadScalar(val)); break; } case ET_DOUBLE: { - visitor->Double(*reinterpret_cast(val)); + visitor->Double(ReadScalar(val)); break; } case ET_STRING: {