[clang] Class gets an implicit default constructor when it has a user-provided constructor
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The following code doesn't compile due to failed static assertion in Clang, but does compile in MSVC:
```C++
struct A
{
template
constexpr A() noexcept {}
};
struct B : A
{
using A::A;
explicit constexpr B(int) noexcept {}
};
struct C : B
{
using B::B;
template
constexpr C() noexcept : a(1) {}
int a = 0;
};
static_assert(C().a == 1);
```
This is not standard compliant, that code should compile. According to the standard A's constructor is not a default constructor per-se, as in "special member function" kind of default constructor -- it is a template for a constructor that takes no arguments, thus A does not have an implicit default constructor, so nor should B which inherits from it and its constructor using the `using` declaration. But clang seems to think here that because A is default-constructible (which it is, despite not having "real" default constructor), that B should get an implicit default constructor.
Contributor guide
Assessment
This issue has not been assessed yet.