From a1f14005ab823adc1300754fd37c01e9842ed4bc Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Thu, 21 Feb 2019 16:50:05 -0800 Subject: [PATCH] Fix big-endian build. (#5205) For some reason, Offset is being considered a scalar, which causes EndianSwap to be passed an Offset. This doesn't work, as it does not support types with non-trivial constructors. This change adds an overload to WriteScalar(), which works around this. --- include/flatbuffers/base.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h index 3e6afc69c..a64a587f2 100644 --- a/include/flatbuffers/base.h +++ b/include/flatbuffers/base.h @@ -363,6 +363,11 @@ void WriteScalar(void *p, T t) { *reinterpret_cast(p) = EndianScalar(t); } +template struct Offset; +template __supress_ubsan__("alignment") void WriteScalar(void *p, Offset t) { + *reinterpret_cast(p) = EndianScalar(t.o); +} + // Computes how many bytes you'd have to pad to be able to write an // "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in // memory).