From 515a4052a750dfe6df8d143c8f23cd8aaf51f9d7 Mon Sep 17 00:00:00 2001 From: Vasyl Gello Date: Mon, 6 Jul 2020 18:38:06 +0300 Subject: [PATCH] Silence false positive "-Wstringop-overflow" on GCC 10.0 to 11.0 (#6020) --- include/flatbuffers/base.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h index bfa02666d..d83c7756e 100644 --- a/include/flatbuffers/base.h +++ b/include/flatbuffers/base.h @@ -381,6 +381,13 @@ T ReadScalar(const void *p) { return EndianScalar(*reinterpret_cast(p)); } +// See https://github.com/google/flatbuffers/issues/5950 + +#if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif + template // UBSAN: C++ aliasing type rules, see std::bit_cast<> for details. __supress_ubsan__("alignment") @@ -393,6 +400,10 @@ template __supress_ubsan__("alignment") void WriteScalar(void *p, Of *reinterpret_cast(p) = EndianScalar(t.o); } +#if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000) + #pragma GCC diagnostic pop +#endif + // 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).