<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61821>61821</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang's algorithm for choosing overloads that don't need to instantiate a class template might have room for improvement
</td>
</tr>
<tr>
<th>Labels</th>
<td>
question,
c++20,
clang:frontend,
concepts
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cjdb
</td>
</tr>
</table>
<pre>
GCC test (`concepts-conv3.C`) currently fails. I think Clang is in the clear for it failing per [[temp.inst]/9](http://wg21.link/temp.inst#9), but I wonder if we ought to mimic GCC here, since it will improve template ergonomics.
```cpp
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
// Here, normal overload resolution would consider B::operator bool when
// evaluating A(b), leading to a hard error instantiating Error<int>, but we
// avoid considering it by noticing that converting bool (a scalar) to A (a
// class) would require a user-defined conversion, which is not allowed when
// we're already dealing with the user-defined conversion to A.
// This seems to be allowed by [temp.inst]/9: "If the function selected by
// overload resolution (12.4) can be determined without instantiating a class
// template definition, it is unspecified whether that instantiation actually
// takes place."
template <class T>
struct Error { static constexpr auto value = T::value; };
struct A { A(const A&); };
template <class T>
struct B { operator bool() requires Error<T>::value; };
template <class T>
concept C = requires (B<T> b) { A(b); };
static_assert(!C<int>);
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVc2y2zYPfRp6g7FGgvwjLbzwT_x92XTRSdcZioItJhSpkJAdv32HtK593d60nblz5SGJgwPwHEKGoM-WaCOWO7E8zOTInfMb9a1tZo1rb5v_7ffAFBgEVmKVK2cVDRzmytlLme3FKhdYgxq9J8vmBiepTcjgM3Cn7XfYG2nPoANoC9wRKEPSw8l50JzOanuGgTyk_Dumfsi0DSyWB4HHOn2qjnkQ5VbgUeDxesYiM9p-F3h8HseyFlgL3EMzMnyGq7MtedAnuBK48dwxsINe91pBLKkjT_F00FZR5HLVxoDu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