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

    <tr>
        <th>Summary</th>
        <td>
            Constraint does not have type bool after substitution 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++20,
            clang:frontend,
            accepts-invalid
      </td>
    </tr>

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

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

<pre>
    Given the following ill-formed C++ code:

```cpp
template<typename T> struct S {
  constexpr operator bool() {return true;}
};

template<typename T> requires(S<T>{})
void f(T);
void f(int);

void g(){f(0);} 
```

clang fails to diagnose this while both gcc and MVCS correctly do godbolt: https://godbolt.org/z/ePnM6Gxvh

see [temp.const.atomic p3](https://eel.is/c++draft/temp.constr.atomic#3), which says:

> To determine if an atomic constraint is satisfied, the parameter mapping and template arguments are first substituted into its expression. If substitution results in an invalid type or expression, the constraint is not satisfied. Otherwise, the lvalue-to-rvalue conversion is performed if necessary, and E shall be a constant expression of type bool. ...

and has this exact example.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VF2P6jgM_TXpi0VVEqDw0IcBhqt9uNqVZrTvbuO22U2TbuIyw_76VShcmJFWqvrh-NjH9nExRtM5okqs92J9zHDi3ocq9tiav7Pa60v1w5zJAfcErbfWfxjXgbF20fowkIaDkHsh99B4TUK9iOIoivt9U8xXM46zhWkYLTIJdeDLSA4HgnehXiFymBqGNxDlfnYFaLyLTJ9jAD9SQPYBau-tkFshd8kxEE_BAYeJhNqL8nhLWx7T5xOR_00b6J_JBIpCbt-EOiRbIlAehdzN0LM3Gloht-_JdA_7y2ocP9ufTruZpyj3ya-4eZVH-NabZ2Bj0XXQorER2IM22DkfCbg3ET56Ywlqzz10TQPoNPz88_AGjQ-BGrYX0B46r2tvWagX6JnHmCYiT0Kebge5D52Qp3-FPNEf7ufmx-e5f2YQiUCs96lh-bX_ObIfTAOjEuujkNuvUYlsbqKQp2ZWgQ7YspCnBz7cAgipVOqBPKRCmh4iXuJ3vahXePegiSkMxhGYFtDBjcEcDo1jMBEisomtIZ0iJnGOGHBISBhwHJNIU4fukwcM3TSQ4wgYCFoTIkOc6siGJyYNxrEHwxGS4ChG410Ov7UPH-MdBIqT5QjGJV7GndEaDUlS4MMT8s7pK2Xn-UE7h9-5p_BhIt297RntRAv2i3B9S_AzhRQwwUcKt5UzLThqKEYMlwROhb5C7NFaqAlwzouOnyiBb2eiaYVyyPP8ufMpQo9xFhp9YpOgOIyW8kxXSu_UDjOqlptSlWq3Xcmsr1Y14Xq30bpupVRqVy9V2zayLWij6nKnM1PJQqpiuVxJtVoVMsflaiPLGrUiuZG0E6uCBjQ2t_Y8JGVmJsaJqk1RqG1msSYbrz8mKW_6koWQUshDsqRdEeqlDd4xOf3rAJuGRo6L23iSfX3MQpWSLOqpi2JVWBM5PtKyYUvV4TEt7WmeV49nevQNsE0C-6KJbAq2-rZrhvupzhs_CHlKSW6PxRj8X9SkBbkWmhbnWut_AQAA__-NAMYa">