<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59827>59827</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang][concepts] Conditional `explicit` specifier is checked too early in constrained constructor
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JMazurkiewicz
</td>
</tr>
</table>
<pre>
Repro:
```c++
template<class X>
constexpr bool is_int = false;
template<>
constexpr bool is_int<int> = true;
template<class X>
concept intish = is_int<X>;
template<class X>
constexpr X get5() {
return X{5};
}
struct S { };
template<bool X>
struct enable_if { };
template<>
struct enable_if<true> {
using type = int;
};
struct T {
#if 1
template<intish X>
#else // ^^^ bug / fine vvv
template<class X,
typename enable_if<is_int<X>>::type = 0>
#endif
constexpr explicit(get5<X>() == 5) T(X) { }
T(S) { }
};
static T u(S{});
```
Expected: *correct compilation*
Got:
```ps1
<source>:12:14: error: excess elements in struct initializer
return X{5};
^
<source>:32:24: note: in instantiation of function template specialization 'get5<S>' requested here
constexpr explicit(get5<X>() == 5) T(X) { }
^
<source>:37:10: note: while substituting deduced template arguments into function template 'T' [with X = S]
static T u(S{});
^
```
Godbolt: https://godbolt.org/z/oc1P17Pss
Discovered in: https://github.com/microsoft/STL/pull/3323
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VUtv4zYQ_jXjy2ADibQs--BD_FqgaIFFk0NuC4oa2ezSpMpHXr--IK34kTrZ9rCCIBPkzDfzzXxjCu_V1hDNoVpAtRqJGHbWzX_7Q7xG90PRk5Kvo8a2L_M_qXcW-C0UKyjevpPi8Epgi_Tm3UD7XotAwJdSC-_xAfj6cCSt8YGee4eNtRqV_65MQOAr7IT2BHxxDn8G9DkC8GX-rjNUcPETpCspSeoDKhOU32WAI2i2-j9IQ2oPuKVQAZsCmyHUAwAioqMQncEHqBcV1KsTeL06j-KDizLgX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