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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Instantiation of concept makes invalid expression valid.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Clang accepts or rejects the code depends on whether a related concept is instantiated before.

[Godbolt link](https://godbolt.org/z/4a5bq1efM)
```c++
#include <concepts>

struct Var {};

template<class T>
constexpr Var var;

struct A {};

template<class T> requires std::same_as<A, T>
constexpr auto var<T> = 1;

template<class T> requires std::same_as<T*, A*>
constexpr auto var<T> = 2;

template<class T>
concept C1 = var<T> == 1;

template<class T>
concept C2 = var<T> == 2;

template<class T>
concept C = C1<T> || C2<T>;

#ifdef __clang__
// static_assert(var<A> == 1 || var<A> == 2); // clang reports error here
auto magic = C1<A>;
static_assert(var<A> == 1 && var<A> == 2 && var<A> == 42);  // clang doesn't report error here
#endif

#ifdef _MSC_VER
 static_assert(var<A> == 1);                 // msvc selects the first specializatioin
    static_assert(C1<A> && !C2<A> && C<A>);
#else
 static_assert(!C1<A> && !C2<A> && !C<A>);   // concept-ids of unsatisfied constraints are false
#endif

template<class T>
struct B;

template<C1 T>
struct B<T> : std::true_type {};

template<std::same_as<A> T>
struct B<T> : std::false_type {};

static_assert(!B<A>::value);    // msvc doesn't treat unsatisfication of C1 as sfinae
```


Minimal example:
```c++
template<class>
constexpr auto x = false;

template<class T> requires true
constexpr auto x<T> = true;

template<class T> requires true && true
constexpr auto x<T> = true;

template<class T>
concept X = x<T>;
// static_assert(x<void>); //error
static_assert(!X<void>);
static_assert(x<void> && !x<void> && **x<void>()[]);
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVk2PozgQ_TXOpTQ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