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

    <tr>
        <th>Summary</th>
        <td>
            [clang++] unexpected `error: substitution into constraint expression resulted in a non-constant expression`
        </td>
    </tr>

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

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

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

<pre>
    Consider the following piece of C++20 code:

```cpp
template<typename> struct property;

template<typename Derived>
struct B {
    void doit() {
        []<typename R, typename... Args>(R (Derived::*)(Args...)) {
 constexpr bool x = requires {
                requires property<R>::value == 3;
            };
        } (&Derived::f);
 }

};

struct A : B<A> {
    int f();
};

void test() {
    A{}.doit();
}
```

`clang++` emits the following diagnostics:

```
<source>:8:26: error: substitution into constraint expression resulted in a non-constant expression
    8 | requires property<R>::value == 3;
      | ^~~~~~~~~~~~~~~~~~~~~~~
<source>:8:26: note: while checking the satisfaction of nested requirement requested here
    8 | requires property<R>::value == 3;
      | ^~~~~~~~~~~~~~~~~~~~~~~
<source>:8:26: note: in instantiation of requirement here
    8 |                 requires property<R>::value == 3;
      | ^~~~~~~~~~~~~~~~~~~~~~~
<source>:8:26: note: while checking the satisfaction of nested requirement requested here
    8 | requires property<R>::value == 3;
      | ^~~~~~~~~~~~~~~~~~~~~~~
<source>:6:67: note: while substituting into a lambda expression here
    6 |         []<typename R, typename... Args>(R (Derived::*)(Args...)) {
      | ^
<source>:20:9: note: in instantiation of member function 'B<A>::doit' requested here
   20 |     A{}.doit();
      | ^
<source>:8:45: note: non-literal type '<dependent type>' cannot be used in a constant expression
    8 |                 requires property<R>::value == 3;
      | ^
```

however gcc, msvc, and edg compile it just fine: https://gcc.godbolt.org/z/7rjG4T6o4
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVs1yozgQfpr2pSsUlvixDx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