lang不会编译匿名结构

时间:2019-11-13 09:01:28

标签: c++ clang++

我的代码如下:

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 {
    ^

我想念什么?

0 个答案:

没有答案
相关问题