Issue |
80963
|
Summary |
Clang fails to detect illegal copy constructor with template class as its parameter
|
Labels |
clang
|
Assignees |
|
Reporter |
Rush10233
|
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)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs