mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-27 02:42:19 +00:00
Silence false positive "-Wstringop-overflow" on GCC 10.0 to 11.0 (#6020)
This commit is contained in:
@@ -381,6 +381,13 @@ T ReadScalar(const void *p) {
|
|||||||
return EndianScalar(*reinterpret_cast<const T *>(p));
|
return EndianScalar(*reinterpret_cast<const T *>(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<typename T>
|
template<typename T>
|
||||||
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
|
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
|
||||||
__supress_ubsan__("alignment")
|
__supress_ubsan__("alignment")
|
||||||
@@ -393,6 +400,10 @@ template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Of
|
|||||||
*reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
|
*reinterpret_cast<uoffset_t *>(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
|
// 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
|
// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
|
||||||
// memory).
|
// memory).
|
||||||
|
|||||||
Reference in New Issue
Block a user