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 e8dcbaaaf6.

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>
bb10
Marc Mutz 2023-06-27 09:14:09 +02:00 committed by Ahmad Samir
parent 6326bec46a
commit 70a7a695fd
1 changed files with 5 additions and 0 deletions

View File

@ -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);
}