RC: suppress compiler warnings with GCC 12 and 13

We're pretty sure that these warnings are false positives.
Both are related to destructing MultiCompleteType objects.

GCC 12 (thread_unsafe_refcount):
rc.hpp:322:18: pointer used after ‘void operator delete(void*, std::size_t)’
[-Wuse-after-free]

GCC 13 (thread_safe_refcount, only arm64):
inlined from ‘...thread_safe_refcount::operator--()’ at .../rc.hpp:404:39
atomic_base.h:645:34: ‘long unsigned int __atomic_sub_fetch_8(...)’ writing
8 bytes into a region of size 0 overflows the destination
[-Werror=stringop-overflow=]

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
This commit is contained in:
Frank Lichtenheld
2023-11-14 17:40:31 +01:00
parent cc58225888
commit dffd6036e0

View File

@@ -304,6 +304,26 @@ class RCWeakPtr
typename T::Controller::Ptr controller;
};
/* We're pretty sure these are false positives. They only occur with very
specific compiler versions and/or architectures.
For some reason some gcc versions think that the reference counter goes
away too soon when destructing certain MultiCompleteType objects. The
warnings/errors do not tell us why they think that.
So for now we display the warnings, but do not fail -Werror builds over
them. So that we can fail them for any other new warnings.
*/
#if !defined(__clang__) && defined(__GNUC__)
#pragma GCC diagnostic push
#if __GNUC__ == 12
#pragma GCC diagnostic warning "-Wuse-after-free"
#endif
#if __GNUC__ == 13
#pragma GCC diagnostic warning "-Wstringop-overflow"
#endif
#endif
class thread_unsafe_refcount
{
public:
@@ -479,6 +499,10 @@ class thread_safe_refcount
std::atomic<olong> rc;
};
#if !defined(__clang__) && defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
// Reference count base class for objects tracked by RCPtr.
// Disallows copying and assignment.
template <typename RCImpl> // RCImpl = thread_safe_refcount or thread_unsafe_refcount