-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Open
Labels
accepts-invalidclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
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: 2Please see https://godbolt.org/z/EbY3zWKc1
Metadata
Metadata
Assignees
Labels
accepts-invalidclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"