From 24cc41f77fefa20d4bf4acb6dd1a96b2371ebfd2 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 19 Mar 2024 09:25:42 +0100 Subject: [PATCH] Suppress bogus warning from gcc 12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It says: /home/qt/qt6dev-src/qtbase/src/corelib/tools/qcontainertools_impl.h: In function ‘auto QtPrivate::sequential_erase_with_copy(Container&, const T&) [with Container = QList; T = void (*)()]’: /home/qt/qt6dev-src/qtbase/src/corelib/tools/qcontainertools_impl.h:383:14: error: ‘D.282000’ is used uninitialized [-Werror=uninitialized] 383 | const T &tCopy = CopyProxy(t); | ^~~~~ cc1plus: all warnings being treated as errors We can avoid storing the value into a const ref to silence this. Storing a non-const pointer into a const reference is quite confusing anyway. Fixes: QTBUG-123486 Pick-to: 6.6 6.5 Change-Id: I77fcd871724ce7f81b9567603dc5b4cb31f121c5 Reviewed-by: Thiago Macieira (cherry picked from commit 4662e80755b3002585280cfe9076d2c6c14f1e5b) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/tools/qcontainertools_impl.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/tools/qcontainertools_impl.h b/src/corelib/tools/qcontainertools_impl.h index fcc6450d5ed..b4b515137d4 100644 --- a/src/corelib/tools/qcontainertools_impl.h +++ b/src/corelib/tools/qcontainertools_impl.h @@ -373,8 +373,7 @@ template auto sequential_erase_with_copy(Container &c, const T &t) { using CopyProxy = std::conditional_t, T, const T &>; - const T &tCopy = CopyProxy(t); - return sequential_erase(c, tCopy); + return sequential_erase(c, CopyProxy(t)); } template