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

    <tr>
        <th>Summary</th>
        <td>
            Clang applies constraint checking loosely in variable declaration with concepts
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            accepts-invalid,
            concepts
      </td>
    </tr>

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

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

<pre>
    The following code compiled with Clang, but not with GCC or MSVC:

```c++
template <class T, class U>
struct is_same { static constexpr bool value = false; };

template <class T>
struct is_same<T, T> { static constexpr bool value = true; };

template <class T, class U>
concept same_as = is_same<T, U>::value;

int const& f();

same_as<int const&> auto& i = f();
```

Both GCC and MSVC complain that the constraint `same_as<int const&>` is not satisfied, but Clang accepts it. If we change to `same_as<int const> auto& i = f();`, then GCC and MSVC accept it, and Clang accepts it too, which is really weird!

Godbolt: https://godbolt.org/z/q5K9885vb

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVMuO2yAU_Rq8QRPZOM5j4UUenVFVddVptyPA1zEtARdw0unX94IT1Y0yVSthsLmPc-7hYmGb1_q5A9pare1ZmQOVtgGcjr3S0NCzCh3daW4OhO2oGAI1Noy7T7sdtY5-_PRlR8oNyfckv86LfBySsG0caTfAsdc8ACXlTmruPX2OOcfXz6R8N7r54AYZqPIvnh_RebmlPvCgJJIyPsCP3lFhraYnroeYbE9brj2QcovOe1ymVO6B3kdCh8Qn2v8JFaP_A_ROpZhZQh9oRH_hPiW9IZOcUdxyk3BvcJQJIz3CFrQlbEXY-sblkhvzTZ1jiXwINsapUcLb6OsRTpNt7eXYuWnSuac-0VwZGjoecIIRwvGIhtFvwqMNa03N5FFm3yporh2W2o1yGcXxVIUZfd_SM6bucB9osG9l_ltVWAmmR4bmzwpGGESJ5rh7i454NtrOnZJd5OyAa_2KhJRDysVUoCfbCKuRyIZ2IfQ-Hh17xHEYDTPr8B49_sTne_VhvVpVJzFGZk1dNutyzbOggob6wqLvtQI_FVV2IL_Fe6qt9YA8UPwTd4oLDbQB7DGHeloz3tFLi_lscLq-oYT2QczwBPFD69N1eeid_QoS9XhU3g_g8aWaz-dl1tVNK2DJq2JVMrFsWV4UsC5kW5awFnkjWKa5AO1rUuG1ZzL9NspN66wJYFAsFoXE5aLugzLY1mpiuPKNO9U-UzXLGcvLYlWs2KJYzCBvl4DgYp4vlm21JPMcjlzpWWQe1c1cnYoQw8GjUSsf_G8j3j91MACJIObHbuksRjQomIEs1VunYn8BFxuUXQ">