I have code below:
struct Foo {
union {
struct {
double d = 1.0;
double f;
};
char c;
};
};
int main() {
Foo foo;
}
this code works fine with GCC, but when using Clang, it won't compile:
main.cpp:13:7: error: call to implicitly-deleted default constructor of 'Foo'
Foo foo;
^
main.cpp:3:5: note: default constructor of 'Foo' is implicitly deleted because variant field '' has a non-trivial default constructor
struct {
^
What do I miss?