From 8196b4d380ccf47dc3e1043cf05e96e0e885db6b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 21 Oct 2024 19:05:07 +0200 Subject: [PATCH] Expand suppression of gcc's free-nonheap-object warning Added a comment to the suppression, to make clear why it's justified. Change-Id: Ibc8aea809a8e9467b3a194a142296ea6b79e1971 Reviewed-by: Thiago Macieira (cherry picked from commit b460d0bd809b10705d2658bfb62cb0d04835c015) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qlocale.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 12af8dc3082..9b1b6d73b9f 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -4,7 +4,15 @@ #include "qglobal.h" -#if (defined(QT_STATIC) || defined(QT_BOOTSTRAPPED)) && defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 1000 +#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 1000 +/* gcc has complained about storing a pointer to a static QLocalePrivate in a + QSharedDataPointer, whose destructor would free the non-heap object if the + refcount ever got down to zero. The static instances this happens to are + instantiated with a refcount of 1 that never gets decremented so as long as + QSharedDataPointer keeps its incref()s and decref()s balanced it'll never get + down to zero - but the clever compiler isn't quite smart enough to figure + that out. +*/ QT_WARNING_DISABLE_GCC("-Wfree-nonheap-object") // false positive tracking #endif