[libcxx-commits] [libcxx] [libc++] Avoid relying on CTAD for std::lock_guard in the benchmarks (PR #225503)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 22 12:47:29 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

<details>
<summary>Changes</summary>

libc++ provides a deduction guide for std::lock_guard, but libstdc++ does not, so the code trips -Wctad-maybe-unsupported when the benchmark is built against libstdc++.

---
Full diff: https://github.com/llvm/llvm-project/pull/225503.diff


1 Files Affected:

- (modified) libcxx/test/benchmarks/stringstream.bench.cpp (+2-2) 


``````````diff
diff --git a/libcxx/test/benchmarks/stringstream.bench.cpp b/libcxx/test/benchmarks/stringstream.bench.cpp
index 052696815236d..123727a3b4988 100644
--- a/libcxx/test/benchmarks/stringstream.bench.cpp
+++ b/libcxx/test/benchmarks/stringstream.bench.cpp
@@ -39,7 +39,7 @@ struct LocaleSelector {
   static std::mutex mutex;
 
   LocaleSelector(benchmark::State& state) {
-    std::lock_guard guard(mutex);
+    std::lock_guard<std::mutex> guard(mutex);
     switch (state.range(0)) {
     case 0: {
       old   = std::locale::global(std::locale::classic());
@@ -67,7 +67,7 @@ struct LocaleSelector {
   }
 
   ~LocaleSelector() {
-    std::lock_guard guard(mutex);
+    std::lock_guard<std::mutex> guard(mutex);
     std::locale::global(old);
   }
 };

``````````

</details>


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


More information about the libcxx-commits mailing list