[libcxx-commits] [libcxx] [libc++][ThreadSafety] Add thread safety annotations for variadic std::scoped_lock (PR #204462)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 18 01:47:23 PDT 2026


================
@@ -65,6 +65,9 @@ Improvements and New Features
   ``"std::visit: variant is valueless"``, ``"std::get: variant is valueless"``, or
   ``"std::get: wrong alternative for variant"``. The standard only requires ``what()`` to return an
   unspecified non-null string, so user code that does not match on the exact message remains correct.
+- ``std::scoped_lock`` now carries Clang thread safety annotations when locking multiple mutexes, so
+  ``-Wthread-safety`` no longer incorrectly reports the guarded data accessed inside the block as
+  unprotected. This requires Clang 21 or later. This fixes `#42000 <https://github.com/llvm/llvm-project/issues/42000>`_.
----------------
philnik777 wrote:

I don't think this is the sort of change that we usually release note. @ldionne @frederick-vs-ja any thoughts?

https://github.com/llvm/llvm-project/pull/204462


More information about the libcxx-commits mailing list