[LLVMbugs] [Bug 19747] New: Crash when initializing more than one member of a union via designated initializer

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 14 15:10:23 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19747

            Bug ID: 19747
           Summary: Crash when initializing more than one member of a
                    union via designated initializer
           Product: clang
           Version: 3.4
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Some ways of specifying initializers for more than one member of a union
through designated initializers causes an assertion failure in Clang.

### SOURCE:> cat designatedInitAssertionFailure.cc 
typedef union { int a, b; } A;

void f() {
   A a[1] = { { .b = 0 }, [0] = { 0 } };
}
Return:  0x00:0


### COMPILER INVOCATION AND OUTPUT:> clang designatedInitAssertionFailure.cc
designatedInitAssertionFailure.cc:4:35: warning: initializer overrides prior
initialization of this subobject [-Winitializer-overrides]
   A a[1] = { { .b = 0 }, [0] = { 0 } };
                                  ^
designatedInitAssertionFailure.cc:4:22: note: previous initialization is here
   A a[1] = { { .b = 0 }, [0] = { 0 } };
                     ^
clang:
/build/workdir/llvm-dev.src/tools/clang/lib/Sema/../../include/clang/AST/Expr.h:3850:
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     0x0000000011f4f1ec llvm::sys::PrintStackTrace(_IO_FILE*) +
4280868572
1  clang     0x0000000011f4f460
2  clang     0x0000000011f5057c
3            0x00000fffb7b80418 __kernel_sigtramp_rt64 + 0
4  libc.so.6 0x00000080b2a06ed8 abort + 4293479816
5  libc.so.6 0x00000080b29fb96c
6  libc.so.6 0x00000080b29fba84 __assert_fail + 4293437460
7  clang     0x00000000109a09bc
8  clang     0x00000000109f29a8
9  clang     0x00000000109f5c8c
10 clang     0x00000000109f65b0
11 clang     0x00000000109f1af8
12 clang     0x00000000109f3648
13 clang     0x00000000109f31f8
14 clang     0x00000000109f567c
15 clang     0x00000000109f6004
16 clang     0x00000000109f65b0
17 clang     0x00000000109f6f98
18 clang     0x00000000109f9a1c
clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity
const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>,
clang::QualType*) + 4259554100
19 clang     0x00000000108709d0 clang::Sema::AddInitializerToDecl(clang::Decl*,
clang::Expr*, bool, bool) + 4258005928
20 clang     0x000000001072b768
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&) + 4256722592
21 clang     0x0000000010738fc0
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 4256777304
22 clang     0x000000001073c2a0
clang::Parser::ParseSimpleDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&,
unsigned int, clang::SourceLocation&,
clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit*)
+ 4256790208
23 clang     0x000000001073c5f4
clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) +
4256791036
24 clang     0x00000000107883c4
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
+ 4257093636
25 clang     0x0000000010789188
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) + 4257097136
26 clang     0x0000000010789d14 clang::Parser::ParseCompoundStatementBody(bool)
+ 4257100044
27 clang     0x000000001078a1d4
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 4257101236
28 clang     0x000000001071f71c
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) +
4256675524
29 clang     0x0000000010738f60
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 4256777208
30 clang     0x0000000010717628
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 4256643088
31 clang     0x0000000010717c58
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 4256644648
32 clang     0x000000001071c2d4
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 4256662284
33 clang     0x000000001071d398
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) +
4256666528
34 clang     0x0000000010712b6c clang::ParseAST(clang::Sema&, bool, bool) +
4256625804
35 clang     0x000000001032d338 clang::ASTFrontendAction::ExecuteAction() +
4252744424
36 clang     0x0000000010527b48 clang::CodeGenAction::ExecuteAction() +
4254705232
37 clang     0x000000001032d094 clang::FrontendAction::Execute() + 4252743820
38 clang     0x00000000103035d4
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 4252576588
39 clang     0x00000000102e0168
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 4252443592
40 clang     0x00000000102d56b8 cc1_main(char const**, char const**, char
const*, void*) + 4252401168
41 clang     0x00000000102de1ac main + 4252435636
42 libc.so.6 0x00000080b29ebcd8
43 libc.so.6 0x00000080b29ebed0 __libc_start_main + 4293374464
Stack dump:
0.      Program arguments: /bin/clang -cc1 -triple powerpc64-unknown-linux-gnu
-S -disable-free -main-file-name designatedInitAssertionFailure.cc
-mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases
-target-cpu ppc64 -target-linker-version 11 -resource-dir /bin/../lib/clang/3.4
-internal-isystem
/usr/lib/gcc/ppc64-redhat-linux/4.4.6/../../../../include/c++/4.4.6
-internal-isystem
/usr/lib/gcc/ppc64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/ppc64-redhat-linux
-internal-isystem
/usr/lib/gcc/ppc64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/backward
-internal-isystem
/usr/lib/gcc/ppc64-redhat-linux/4.4.6/../../../../include/ppc64-redhat-linux/c++/4.4.6
-internal-isystem /usr/local/include -internal-isystem
/bin/../lib/clang/3.4/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fno-dwarf-directory-asm -fdebug-compilation-dir /tmp/hstong -ferror-limit 19
-fmessage-length 0 -mstackrealign -fno-signed-char -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-slp -o
/tmp/designatedInitAssertionFailure-5b86f5.s -x c++
designatedInitAssertionFailure.cc
1.      designatedInitAssertionFailure.cc:4:40: current parser token ';'
2.      designatedInitAssertionFailure.cc:3:10: parsing function body 'f'
3.      designatedInitAssertionFailure.cc:3:10: in compound statement ('{}')
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.4 (tags/RELEASE_34/final)
Target: powerpc64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ 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/designatedInitAssertionFailure-0f9b6c.cpp
clang: note: diagnostic msg: /tmp/designatedInitAssertionFailure-0f9b6c.sh
clang: note: diagnostic msg:

********************
Return:  0xfe:254


### VERSION INFO:> clang -v
clang version 3.4 (tags/RELEASE_34/final)
Target: powerpc64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.4
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Selected GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Return:  0x00:0

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140514/2263bcd8/attachment.html>


More information about the llvm-bugs mailing list