Open
Description
Consider the following code:
template<typename T>
class Box
{
public:
Box(const Box<int>&)=default;
//Box(const Box<T>&)=default;
};
The constructor of class Box
in line 5 should be a normal user-defined constructor instead of a copy constructor as the parameter list is incompatible(the real copy ctor should be in the form of that in line 6), so it should not be declared as defaulted. Both GCC and MSVC reject the code, but clang accepts it.
MSVC provides the following diagnostic:
example.cpp
<source>(6): error C2610: 'Box<T>::Box(const Box<int> &)': is not a special member function or comparison operator which can be defaulted
<source>(6): note: the template instantiation context (the oldest one first) is
<source>(3): note: while compiling class template 'Box'
Compiler returned: 2
Please see https://godbolt.org/z/EbY3zWKc1