我的代码如下:
struct Foo {
union {
struct {
double d = 1.0;
double f;
};
char c;
};
};
int main() {
Foo foo;
}
此代码在GCC上可以正常使用,但是在使用Clang时,它将无法编译:
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 {
^
我想念什么?