Hello.

The following code, which was only generating two warnings with an old version of clang, now also causes a crash.

$ cat bug.c
struct S {
  union U {
    int i;
    double d;
  } u;
};

struct S s = {
  .u = { .i = 0, .d = 0.0 },
  .u = { 0 },
};

$ clang -c bug.c
bug.c:9:19: warning: initializer overrides prior initialization of this
      subobject [-Winitializer-overrides]
  .u = { .i = 0, .d = 0.0 },
                 ~^
bug.c:9:15: note: previous initialization is here
  .u = { .i = 0, .d = 0.0 },
              ^
bug.c:10:10: warning: initializer overrides prior initialization of this
      subobject [-Winitializer-overrides]
  .u = { 0 },
         ^
bug.c:9:23: note: previous initialization is here
  .u = { .i = 0, .d = 0.0 },
                      ^~~
llvm/tools/clang/lib/Sema/../../include/clang/AST/Expr.h:3830: void clang::InitListExpr::setInitializedFieldInUnion(clang::FieldDecl*): Assertion `(FD == 0 || getInitializedFieldInUnion() == 0 || getInitializedFieldInUnion() == FD) && "Only one field of a union may be initialized at a time!"' failed.
[...]
19 clang 0x00000000014ef843 clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) + 7919 20 clang 0x000000000132621a clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool, bool) + 4648
[...]
clang version 3.5 (trunk 195545)
Target: x86_64-unknown-linux-gnu


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to