Issue |
136559
|
Summary |
Clang treats nested classes as non-default-constructible if they have member intializers, until the end of the outer class
|
Labels |
clang
|
Assignees |
|
Reporter |
HolyBlackCat
|
This is the same issue as described in this [very old stackoverflow question](https://stackoverflow.com/q/17430377/2752075).
https://gcc.godbolt.org/z/rP5YvqGfP
```cpp
#include <variant>
struct A
{
struct X
{
int x = 10;
int y = 20;
};
struct Y
{
std::variant<X /*, ...*/> var; // error: call to implicitly-deleted default constructor of 'A::Y'
};
};
int main()
{
A::Y y;
}
```
This compiles on GCC and MSVC. But Clang threats `std::variant<X>` as not default-constructible (because it first checks the default-constructibility of `X` when the variant is declared, and it doesn't consider it to be default-constructible at that point because it has default member initializers and no user-declared default ctor).
GCC used to fail on this too, but it has since been fixed. So presumably there's no technical reason why Clang couldn't accept this as well?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs