<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60710>60710</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang incorrectly instantiates conditional-explicit even when constraints are not satisfied
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            rejects-valid
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ldionne
      </td>
    </tr>
</table>

<pre>
    In code like the following, Clang will instantiate the content of the conditional-explicit even when the constraint is not satisfied:

```
template <some-constraint T>
 explicit(some-expression-involving-T)
constructor(T const&) { }
```

As a result, if `some-expression-involving-T` is not well-formed, Clang will issue a hard error even if `some-constraint` is not satisfied, in which case one would have expected that the constructor is removed from the overload sets instead.

Full reproducer:

```
// clang++ -xc++ - -std=c++2b -fsyntax-only
#include <type_traits>
#include <utility>

template <class ...T>
struct tuple { };

template <class T>            struct IsPairLikeImpl : std::false_type { };
template <class T1, class T2> struct IsPairLikeImpl<tuple<T1, T2>> : std::true_type { };
template <class T> concept IsPairLike = IsPairLikeImpl<T>::value;

template <class ...T>
constexpr auto f(tuple<T...> const&) {
 static_assert(sizeof...(T) == 2);
}

template <class T1, class T2>
struct pair {
    template <IsPairLike P>
 explicit(std::is_void_v<decltype(f(std::declval<P>()))>)
    pair(P const&) { }
};

template <class T>
concept can_construct_pair_from = requires (T t) {
    pair<int, int>(t);
};

static_assert(!can_construct_pair_from<tuple<int>>);
static_assert( can_construct_pair_from<tuple<int, int>>);
static_assert(!can_construct_pair_from<tuple<int, int, int>>);

int main() { }
```

Godbolt link: https://godbolt.org/z/7PjGqdjes

GCC and MSVC accept this code, Clang doesn't. This was discovered while trying to implement `pair-like` constructors for libc++.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVltv6jgQ_jXmZZQocQqBBx4oLEdH2pUqbbWvyNgTcOvYObYT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