| Issue |
167136
|
| Summary |
[clang] Class gets an implicit default constructor when it has a user-provided constructor
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
carljohnsonnewhampshire-hue
|
The following code doesn't compile due to failed static assertion in Clang, but does compile in MSVC:
```C++
struct A
{
template <int=0>
constexpr A() noexcept {}
};
struct B : A
{
using A::A;
explicit constexpr B(int) noexcept {}
};
struct C : B
{
using B::B;
template <int=0>
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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs