<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61824>61824</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang doesn't SFINAE out constrained overload when substitution-failure happens in template-head
</td>
</tr>
<tr>
<th>Labels</th>
<td>
question,
c++20,
clang:frontend,
rejects-valid,
concepts
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cjdb
</td>
</tr>
</table>
<pre>
GCC test `concepts-defarg2.C` fails in Clang. I'm not sure if GCC should be accepting the original lines, but Clang gets suspicious when I uncomment my addition (which I don't think should be failing).
```cpp
// PR c++/97052
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
template<typename T, typename U = typename T::type>
concept C = true;
constexpr bool f(C auto) {
return true;
}
// added by me
// constexpr bool f(auto) {
// return true;
// }
static_assert(f(0));
C auto x = 0;
```
Diagnostics prior to uncommenting:
```
<source>:16:15: error: no matching function for call to 'f'
static_assert(f(0));
^
<source>:7:16: note: candidate template ignored: constraints not satisfied [with auto:1 = int]
constexpr bool f(C auto) {
^
<source>:4:44: note: because substituted constraint expression is ill-formed: type 'int' cannot be used prior to '::' because it has no members
template<typename T, typename U = typename T::type>
^
<source>:4:44: error: type 'int' cannot be used prior to '::' because it has no members
template<typename T, typename U = typename T::type>
^
note: in instantiation of default argument for 'C<int>' required here
```
Diagnostics after uncommenting:
```
<source>:4:44: error: type 'int' cannot be used prior to '::' because it has no members
template<typename T, typename U = typename T::type>
^
note: in instantiation of default argument for 'C<int>' required here
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVtGPo7YT_mucl1EiYkISHnjIks1P-3L66dp7Phl7AF-Nzdnjvct_XxmSTfa6VbdVVbWIQLDNzDfffINHhKA7i1ix4oEVx4WI1DtfyS-qWTROnav_1TUQBgK2zaSzEkcKS4Wt8B1f1WybQSu0CaAt1EbYbgVPjO8GsI4gRI-g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