From cf1a20df70cb7049085b07555b593565fa437e7f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 12 Jun 2025 14:41:01 +0200 Subject: [PATCH] tst_QPointer: fix Clang 19 -Wunused-lambda-capture Clang informs that ITERATIONS_PER_THREAD need not be captured: tst_qpointer.cpp:548:66: warning: lambda capture 'ITERATIONS_PER_THREAD' is not required to be captured for this use [-Wunused-lambda-capture] 548 | QThread::create([&startSemaphore, &targetObject, ITERATIONS_PER_THREAD]() { | ~~^~~~~~~~~~~~~~~~~~~~~ Make ITERATIONS_PER_THREAD (and NUM_THREADS, while at it) constexpr, indicating even to non-language-lawyers that these variables, indeed, need not be captured, then drop the capture. Amends 253f34082f526ff1ffd9eaefac73cc9aa616ab2a. Pick-to: 6.9 6.8 6.5 Change-Id: I27d94763058e1dcea3a65d4ff2c859b40336446f Reviewed-by: David Faure (cherry picked from commit 668d81f73a5c2f4ec14764d1892f2eaf6494c0f1) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp index 7968aa6fcb4..c469575c23a 100644 --- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp +++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp @@ -533,8 +533,8 @@ void tst_QPointer::threadSafety() void tst_QPointer::raceCondition() { - const int NUM_THREADS = 20; - const int ITERATIONS_PER_THREAD = 10; + constexpr int NUM_THREADS = 20; + constexpr int ITERATIONS_PER_THREAD = 10; QSemaphore startSemaphore; @@ -545,7 +545,7 @@ void tst_QPointer::raceCondition() for (int i = 0; i < NUM_THREADS; ++i) { QThread *thread = - QThread::create([&startSemaphore, &targetObject, ITERATIONS_PER_THREAD]() { + QThread::create([&startSemaphore, &targetObject] { startSemaphore.acquire(); for (int j = 0; j < ITERATIONS_PER_THREAD; ++j) {