<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60293>60293</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang c++20: Associated constraints added to a default constructor are excessively checked
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
frederick-vs-ja
</td>
</tr>
</table>
<pre>
In the following code snippet, the declaration of typedef-name `CW` is accepted by msvc and gcc, but rejected by clang. [Godbolt link](https://godbolt.org/z/bGMdTh8qs).
I think clang is probably buggy here. When determining whether `decltype(ConstrainedWrapper<Wrapped>{std::declval<Wrapped>()})` is well-formed, clang seemly excessively requires the associated constraints of the default constructor to be satisfied, even if the default constructor is not selected.
```C++
#include <concepts>
#include <cstddef>
#include <utility>
struct NoDefaultCtor {
constexpr explicit NoDefaultCtor(std::nullptr_t) {}
};
template<class T>
struct Wrapper {
Wrapper() = default;
constexpr explicit Wrapper(T x) : val(std::move(x)) {}
T val{};
};
template<class T>
struct ConstrainedWrapper {
ConstrainedWrapper() requires std::default_initializable<T> = default;
constexpr explicit ConstrainedWrapper(T x) : val(std::move(x)) {}
T val{};
};
using Wrapped = Wrapper<NoDefaultCtor>;
using W [[maybe_unused]] = decltype(Wrapper<Wrapped>{std::declval<Wrapped>()});
using CW [[maybe_unused]] = decltype(ConstrainedWrapper<Wrapped>{std::declval<Wrapped>()}); // <- clang is buggy here
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VUtv4zoP_TXKhkjgyImdLLzIYzKYxfetCnRZ6EHHmsqSR5LTZn79hSw3j05mFvde3MJQA9MkzyGpQ-a9OhrEiiy3ZLmfsD401lW1Q4lOidfpyU-_swm38lx9MxAahNpqbd-UOYKwEsEb1XUYCN0NVolCM8eCsgZsDeHcocR6aliLQIps90yKDJQHJgR2ASXwM7T-JIAZCUchYhzeB3D4HcVoF5qZ4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