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

    <tr>
        <th>Summary</th>
        <td>
            Clang fails to detect illegal copy constructor with template class as its parameter
        </td>
    </tr>

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

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

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

<pre>
    The following code is apparently illegal, as the declaration of `A(A<T,T>)` should be treated as a copy constructor, which forces passing the argument by reference. While clang ignores that error and accepts it:

```c++
template < class T, class V > struct A
{
    A ();
    A (A &);
    A (A < V,T >);
};

void f () 
{
 A <int, int> (A < int, int >());
}
```

Note that if replace `A<V,T>` with `A<T,T>` or `A<V,V>`, the code is still accepted. But when replacing it with `A<T,V>`, the code is correctly rejected.

Reducing the number of template class arguments to 1 (`template <class T> A` and `A(A<T>)`) also makes sense. We suspect the bug will occur only if the template argument list in copy ctor parameter is not identical to that in class declaration.

[https://godbolt.org/z/GKv3E6c4f](https://godbolt.org/z/GKv3E6c4f)


 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVM1u6zgPfRp5Q9xAkZK4XnjRpsm3-IBZXBSdtSzRtmYUyZDkBp2nH9A_TZqLCwwQyAatkIfnHFKlZDuPWLP9C9u_FmrMfYj1zzH1Wy6kLJpgPuu3HqENzoWr9R3oYBBsAjUMKqLP7hOsc9gpx8QRVILcIxjUTkWVbfAQWmAH_szE0zOTxzcmjm9Mnpio2IFD6sPoDDQIOaLKaCiDAh2GT9DBpxxHnUOk1Nfe6h7aEDUmGAi676ZiKnbjBX2G5hMithjRa9zAn711CNop34HtfIhI2FQGjDFEUN6A0hqHnMBmJp8Zf2V8PQ98_mkmXug3RTNeBqcyApNHSpwSUDvL6zsweYIZMax5yuWvAADPwMQT9S0fg3QcfvdFHuGdSIOFtfUOK19v79P5EayBdqkCjwimVNZnQkwPeboVuIXnKhPMh1rfibmv-0fIOFNrW4g4OKVx1lwe31e9DxyuNvdr_O0uHuL97fc5SnhI3dVvKVvnFsXQbOBlzHDt0S8FyQw2_1LiN8l0iBE1eTfiX6gp4X1DP9GMerWXHy8NRrLxl_6z4KvvEuQA24n2A7_3yGoReQIibrLct1FYx4DkUi4FuKi_MUFCn8jACGlMA-o84WjGDq7EQdB6jBA8TV47ffoq-jUKzqYM1i-DlEOEQUV1wYyR-vchgzXos9XKEfxZPb90dje-33hh-5c-5yHRtIgzE-cumCa4vAmxY-L8DxPn__3_Q54Oetey_SsTT__9uqi-VZo9W5hamkpWqsB6W_JSci4lL_palnJX7VXZKLOtStFUZleWXGxbzSWvlC5sLbjYccHLLed7yTdSiHLfqq3EypRSaLbjeFHWbZz7uBCiwqY0Yv3Eq4MsnGrQpWkvCjHtECYErchY0_0fzdgltuNEc7plyDY7rI_TymmVdZMzDGaScFmSv6y22bKP1qKdlG6aFWN09QOXNvdjs9HhwsSZECyPH0MMZGkmzlNDiYnz1NO_AQAA__89n8rq">