<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Crash with simple union initializers"
   href="http://llvm.org/bugs/show_bug.cgi?id=19002">19002</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crash with simple union initializers
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>abramo.bagnara@bugseng.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>abramo@igor:/tmp$ cat z.c
union a {
  float f;
  int i;
};

void f() {
  union a v[2] = {
    [0] = { .i = 0 },
    [0] = { }
  };
}
abramo@igor:/tmp$ _clang -c z.c
clang:
/home/abramo/llvm_trunk/tools/clang/lib/Sema/../../include/clang/AST/Expr.h:3849:
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.
0  clang           0x0000000003405b0b llvm::sys::PrintStackTrace(_IO_FILE*) +
38
1  clang           0x0000000003405d88
2  clang           0x00000000034057de
3  libpthread.so.0 0x00007f8e2b375cb0
4  libc.so.6       0x00007f8e2a39b425 gsignal + 53
5  libc.so.6       0x00007f8e2a39eb8b abort + 379
6  libc.so.6       0x00007f8e2a3940ee
7  libc.so.6       0x00007f8e2a394192
8  clang           0x00000000013c1c3c
9  clang           0x00000000014a9fc6
10 clang           0x00000000014a776b
11 clang           0x00000000014a6f43
12 clang           0x00000000014a7c1d
13 clang           0x00000000014aaf85
14 clang           0x00000000014ad27c
15 clang           0x00000000014a9773
16 clang           0x00000000014a783c
17 clang           0x00000000014a6f43
18 clang           0x00000000014a6759
19 clang           0x00000000014b9555
clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity
const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>,
clang::QualType*) + 7891
20 clang           0x00000000012c66ba
clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool, bool) +
4596
21 clang           0x0000000001182b43
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&) + 2307
22 clang           0x0000000001181cb3
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1429
23 clang           0x000000000118113e
clang::Parser::ParseSimpleDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&,
unsigned int, clang::SourceLocation&,
clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit*)
+ 618
24 clang           0x0000000001180e8c
clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 666
25 clang           0x00000000011d1f32
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
+ 846
26 clang           0x00000000011d1890
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) + 128
27 clang           0x00000000011d4457
clang::Parser::ParseCompoundStatementBody(bool) + 1193
28 clang           0x00000000011da4be
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 322
29 clang           0x00000000011708da
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) +
3220
30 clang           0x0000000001181947
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 553
31 clang           0x000000000116f948
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 1022
32 clang           0x000000000116fa39
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 189
33 clang           0x000000000116f1fc
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 2836
34 clang           0x000000000116e69d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 535
35 clang           0x000000000116830a clang::ParseAST(clang::Sema&, bool, bool)
+ 606
36 clang           0x0000000000ce27b4 clang::ASTFrontendAction::ExecuteAction()
+ 322
37 clang           0x0000000000f55a11 clang::CodeGenAction::ExecuteAction() +
1359
38 clang           0x0000000000ce22e7 clang::FrontendAction::Execute() + 205
39 clang           0x0000000000cb65de
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 720
40 clang           0x0000000000c84360
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1026
41 clang           0x0000000000c76227 cc1_main(char const**, char const**, char
const*, void*) + 717
42 clang           0x0000000000c7ff19 main + 785
43 libc.so.6       0x00007f8e2a38676d __libc_start_main + 237
44 clang           0x0000000000c74909
Stack dump:
0.    Program arguments: /home/abramo/llvm_trunk/Debug+Asserts/bin/clang -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name z.c -mrelocation-model static -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -target-linker-version 2.22 -coverage-file /tmp/z.o
-resource-dir /home/abramo/llvm_trunk/Debug+Asserts/bin/../lib/clang/3.5
-internal-isystem /usr/local/include -internal-isystem
/home/abramo/llvm_trunk/Debug+Asserts/bin/../lib/clang/3.5/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 80
-mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics
-vectorize-slp -o z.o -x c z.c 
1.    z.c:10:4: current parser token ';'
2.    z.c:6:10: parsing function body 'f'
3.    z.c:6:10: in compound statement ('{}')
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.5 (trunk 202045)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/z-e96a6a.c
clang: note: diagnostic msg: /tmp/z-e96a6a.sh
clang: note: diagnostic msg:</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>