diff options
author | Grigoris Pavlakis <grigpavl@ece.auth.gr> | 2021-08-26 02:32:19 +0300 |
---|---|---|
committer | Grigoris Pavlakis <grigpavl@ece.auth.gr> | 2021-09-15 00:07:21 +0300 |
commit | abef2b7194d5dd7aac09e3817598dcce86ae2333 (patch) | |
tree | c9c50af6453fb6cc7da8a69c9a1a53dcf1706c06 /core/templates | |
parent | 0232a031772d929c00d7c8a7947b1b9894ce26fb (diff) |
Fix placement new on zero-sized region warning on GCC 11.1
On latest (11.1 as of this commit) GCC, the following warning is
continuously issued during build:
warning: placement new constructing an object of type
'SafeNumeric<unsigned int>' and size '4' in a region of type
'uint32_t*' {aka 'unsigned int*'} and size '0' [-Wplacement-new=]
This happens because on 98ceb60eb4 the new operator override used
was dropped and replaced with standard placement new. GCC sees the
subtraction from the pointer and complains as it thinks that the
SafeNumeric is placed outside an allocation, not knowing that the
address requested is already inside one.
After suggestions, the false positive is silenced, with no other
changes.
Diffstat (limited to 'core/templates')
-rw-r--r-- | core/templates/cowdata.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/templates/cowdata.h b/core/templates/cowdata.h index ba9babe0af..9b8c0eb528 100644 --- a/core/templates/cowdata.h +++ b/core/templates/cowdata.h @@ -49,6 +49,12 @@ class VMap; SAFE_NUMERIC_TYPE_PUN_GUARANTEES(uint32_t) #endif +// Silence a false positive warning (see GH-52119). +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wplacement-new" +#endif + template <class T> class CowData { template <class TV> @@ -380,4 +386,8 @@ CowData<T>::~CowData() { _unref(_ptr); } +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif + #endif // COWDATA_H |