summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-07-01 22:37:10 +0200
committerMarc Mutz <[email protected]>2025-07-03 00:33:31 +0200
commit1de46a1cda8762b138df7ebde87cd761a7c7c8d9 (patch)
tree21f4a063726065341671358038a9336c3aa0ee0e
parent7d11a03aea09275e1b83031968a2d822376484c9 (diff)
QtTest WatchDog: fix UB (default-constructed std::atomic)
Up to C++17 inclusive, a default-constructed std::atomic object can only be initialized using std::atomic_init(), _not_ by .store(). While it's probably not a problem in practice, it's also not much work to call the std::atomic<T>(T) ctor in the ctor-init-list instead of the implicit default constructor, followed by a store() in the body of the ctor, so do that. Amends a8a38f7caabb90113a229629c6fe463acdecd10f. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I9ba953d1bc34fe09326554a65393b8a2deb35328 Reviewed-by: David Faure <[email protected]>
-rw-r--r--src/testlib/qtestcase.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index f4aa45be73e..53cc849e23c 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1176,10 +1176,10 @@ class WatchDog : public QThread
public:
WatchDog()
+ : expecting{ThreadStart}
{
setObjectName("QtTest Watchdog"_L1);
auto locker = qt_unique_lock(mutex);
- expecting.store(ThreadStart, std::memory_order_relaxed);
start();
waitFor(locker, ThreadStart);
}