Issue |
63288
|
Summary |
Undeserved -Wctad-maybe-unsupported warnings on std::lock_guard, std::scoped_lock
|
Labels |
new issue
|
Assignees |
|
Reporter |
N-Dekker
|
The warning `-Wctad-maybe-unsupported` could certainly be helpful to avoid accidental uses of CTAD on a template that _may not intend to support class template argument deduction_ However, `std::lock_guard` and `std::scoped_lock` are actually _motivating examples_ for the introduction of the language feature with C++17. Looking at [p0091r3 - Template argument deduction for class templates (Rev. 6)](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0091r3.html), by Mike Spertus, Faisal Vali, and Richard Smith, 2016-06-24.
Example (tried using clang 16.0.0 at https://godbolt.org/z/oMW4MbY4M):
```
#include <mutex>
#include <shared_mutex>
std::shared_lock<std::shared_timed_mutex> r1;
std::shared_timed_mutex mut_;
auto lock = std::scoped_lock(mut_, r1); // Gets a "may not intend to support CTAD" warning!
```
Output:
> warning: 'scoped_lock' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
`std::lock_guard` and `std::scoped_lock` are obviously intended to support CTAD, so the warning is undeserved in this case. Could `-Wctad-maybe-unsupported` possibly skip `std::lock_guard` and `std::scoped_lock` somehow? Or could those two templates possibly be marked "intended for CTAD"?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs