From b41356658e522f8fbc1061c4f4c76f0ba17b6acd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 18 Nov 2021 18:08:00 -0800 Subject: QLocale: suppress annoying GCC warning in the bootstrap lib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Happens on line: return QList() << QLocale(QLocale::C); QLocale's constructor taking the C "language" calls findLocalePrivate() that returns indeed the non-heap object c_locale in the c_private() function. But it also sets the refcount to 1, meaning it can never drop to 0 under proper refcounting and will thus never be deleted. Therefore, the compiler is wrong. I don't have time to figure out how to teach it that the deletion can never happen. I just want the warning to go away. It wsa probably introduced by commit d4242b8af3e6eb5e9f68e5ff2efee97de11da892. In destructor ‘QSharedDataPointer::~QSharedDataPointer() [with T = QLocalePrivate]’, inlined from ‘QLocale::~QLocale()’ at /home/tjmaciei/src/qt/qt6/qtbase/src/corelib/text/qlocale.cpp:1035:1, inlined from ‘void QtPrivate::QMovableArrayOps::emplace(qsizetype, Args&& ...) [with Args = {QLocale}; T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qarraydataops.h:829:5, inlined from ‘T& QList::emplaceBack(Args&& ...) [with Args = {QLocale}; T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qlist.h:891:15, inlined from ‘void QList::append(QList::rvalue_ref) [with T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qlist.h:479:24, inlined from ‘QList& QList::operator<<(QList::rvalue_ref) [with T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qlist.h:726:13, inlined from ‘static QList QLocale::matchingLocales(QLocale::Language, QLocale::Script, QLocale::Territory)’ at /home/tjmaciei/src/qt/qt6/qtbase/src/corelib/text/qlocale.cpp:2684:54: /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qshareddata.h:91:55: warning: ‘void operator delete(void*, std::size_t)’ called on unallocated object ‘c_locale’ [-Wfree-nonheap-object] 91 | ~QSharedDataPointer() { if (d && !d->ref.deref()) delete d; } | ^~~~~~~~ Pick-to: 6.2 Change-Id: Iccb47e5527544b6fbd75fffd16b8d078987b812b Reviewed-by: Edward Welbourne --- src/corelib/text/qlocale.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 627b394127..45794cc703 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2019 Intel Corporation. +** Copyright (C) 2021 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -40,6 +40,10 @@ #include "qglobal.h" +#if (defined(QT_STATIC) || defined(QT_BOOTSTRAPPED)) && defined(Q_CC_GNU) && Q_CC_GNU >= 1000 +QT_WARNING_DISABLE_GCC("-Wfree-nonheap-object") // false positive tracking +#endif + #if defined(Q_OS_MACOS) # include "private/qcore_mac_p.h" # include -- cgit v1.2.3