summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread/qfuturesynchronizer
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-06-24 19:41:15 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-06-28 01:09:58 +0300
commit3a9526468c134b68b64b9a3bb6278d47c266e381 (patch)
tree95bb05fc7648b4eb8c9c6324fa4ba9ac65eb851b /tests/auto/corelib/thread/qfuturesynchronizer
parent70a7a695fdbaccd042aa4371cbb231ced2d9b499 (diff)
Handle a couple of GCC 13 warnings about dangling references
There are two temporaries, reply.arguments() returns a temporary QList and list.at(0) returns a temporary reference to the first element. The local reference variable would only extend the lifetime of the temporary object it's bound to, list.at(0), but not the temporary list itself. Even though this a false positive in this case because QList is implicilty shared, the compiler can't tell the difference and the fix is simple. tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp:1845:21: warning: possibly dangling reference to a temporary [-Wdangling-reference] 1845 | const QVariant &retval = reply.arguments().at(0); | ^~~~~~ tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp:1845:50: note: the temporary was destroyed at the end of the full expression ‘QDBusMessage::arguments() const().QList<QVariant>::at(0)’ 1845 | const QVariant &retval = reply.arguments().at(0); | ~~~~~~~~~~~~~~~~~~~~^~~ Pick-to: 6.6 6.5 5.15 Change-Id: I03d54b56769cbd0f9f1165e4679ec4947267181a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/thread/qfuturesynchronizer')
-rw-r--r--tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp b/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp
index e198bb931e..0602afc970 100644
--- a/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp
+++ b/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp
@@ -50,7 +50,12 @@ void tst_QFutureSynchronizer::setFutureAliasingExistingMember()
// around to avoid the warning, as the extra copy would cause a detach()
// of m_futures inside setFuture() with the consequence that `f` no longer
// aliases an element in m_futures, which is the goal of this test.
+QT_WARNING_PUSH
+#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 1301
+QT_WARNING_DISABLE_GCC("-Wdangling-reference")
+#endif
const auto &f = synchronizer.futures().constFirst();
+QT_WARNING_POP
synchronizer.setFuture(f);
}