From 21c3f17eaa9aa4ad56c8f74e3f67c52420a3fbc7 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 7 Mar 2024 21:49:48 +0100 Subject: [PATCH] QGlobalStatic: suppress -Wtsan warning QGS employs a call to std::atomic_thread_fence. Unfortunately TSAN does not support it, and GCC >= 11 raises a warning. This breaks the build when building under -Werror. Suppress the warning using the usual pragmas. There's a catch: qglobalstatic.h is built into a PCH, and GCC <= 13 will still generate a warning because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 . Change-Id: I770f39b7563b66f483851444cd580bcafc5f288a Pick-to: 6.6 6.5 Reviewed-by: Thiago Macieira (cherry picked from commit 143bcbb96f512d8e4014f0abba99f8e7a8729499) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/global/qglobalstatic.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index c7fbba69e81..93127adab36 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -40,8 +40,16 @@ template union Holder ~Holder() { + // TSAN does not support atomic_thread_fence and GCC complains: + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97868 + // https://github.com/google/sanitizers/issues/1352 +QT_WARNING_PUSH +#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 1100 +QT_WARNING_DISABLE_GCC("-Wtsan") +#endif // import changes to *pointer() by other threads before running ~PlainType(): std::atomic_thread_fence(std::memory_order_acquire); +QT_WARNING_POP pointer()->~PlainType(); guard.storeRelease(QtGlobalStatic::Destroyed); }