summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread/qfuturesynchronizer
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-06-27 09:14:09 +0200
committerAhmad Samir <a.samirh78@gmail.com>2023-06-28 01:09:58 +0300
commit70a7a695fdbaccd042aa4371cbb231ced2d9b499 (patch)
treefb1373b6a767b49a24ae371fc0f8d125b72a0aec /tests/auto/corelib/thread/qfuturesynchronizer
parent6326bec46a618c72feba4a2bb994c4d475050aed (diff)
tst_QFutureSynchronizer: describe how setFutureAliasingExistingMember() works
So no-one 'fixes' the test by pinning synchronizer.futures() into a named variable or collapsing the two lines into one. Both would break the premiss of the test. Amends e8dcbaaaf61ee2164db61e70a5d61d7a5b849371. Pick-to: 6.6 6.5 6.2 Change-Id: I7a98c382a7db0bf3ff369dcaf61af0942796d6a3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
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 b2efd6473b..e198bb931e 100644
--- a/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp
+++ b/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp
@@ -45,6 +45,11 @@ void tst_QFutureSynchronizer::setFutureAliasingExistingMember()
// WHEN: calling setFuture() with an alias of the QFuture already in `synchronizer`:
//
for (int i = 0; i < 2; ++i) {
+ // The next line triggers -Wdangling-reference, but it's a FP because
+ // of implicit sharing. We cannot keep a copy of synchronizer.futures()
+ // 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.
const auto &f = synchronizer.futures().constFirst();
synchronizer.setFuture(f);
}