[LLVMbugs] [Bug 17032] New: Clang++ crashes on struct with reference in union
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Aug 28 22:08:33 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17032
Bug ID: 17032
Summary: Clang++ crashes on struct with reference in union
Product: clang
Version: 3.2
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: mjbshaw at hotmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
I have tested this with clang 3.2 on OS X 10.8.4 and clang 3.1 on Scientific
Linux, both of which result in a crash in clang. Steps to reproduce:
First, the code (entire contents of a.cpp):
struct S
{
int x;
int& y = x;
};
union U
{
S s;
};
Compile with:
clang++ -std=c++11 -c a.cpp
It should crash at this point. The output from clang 3.1 on Scientific Linux
is:
found no explanation for non-trivial member
UNREACHABLE executed at
/tmp/adamp/llvm-3.1.src/tools/clang/lib/Sema/SemaDecl.cpp:9326!
0 clang 0x0000000001de946f
1 clang 0x0000000001deb6ba
2 libpthread.so.0 0x0000003ccf60f500
3 libc.so.6 0x0000003ccee328a5 gsignal + 53
4 libc.so.6 0x0000003ccee34085 abort + 373
5 clang 0x0000000001dd2652 llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int) + 354
6 clang 0x00000000009e95b9
clang::Sema::DiagnoseNontrivial(clang::RecordType const*,
clang::Sema::CXXSpecialMember) + 2425
7 clang 0x00000000009e9c52
clang::Sema::CheckNontrivialField(clang::FieldDecl*) + 674
8 clang 0x00000000009fa2f0
clang::Sema::CheckFieldDecl(clang::DeclarationName, clang::QualType,
clang::TypeSourceInfo*, clang::RecordDecl*, clang::SourceLocation, bool,
clang::Expr*, bool, clang::SourceLocation, clang::AccessSpecifier,
clang::NamedDecl*, clang::Declarator*) + 832
9 clang 0x00000000009faa77 clang::Sema::HandleField(clang::Scope*,
clang::RecordDecl*, clang::SourceLocation, clang::Declarator&, clang::Expr*,
bool, clang::AccessSpecifier) + 647
10 clang 0x0000000000a2ba31
clang::Sema::ActOnCXXMemberDeclarator(clang::Scope*, clang::AccessSpecifier,
clang::Declarator&, clang::ASTMultiPtr<clang::TemplateParameterList*>,
clang::Expr*, clang::VirtSpecifiers const&, bool) + 1505
11 clang 0x000000000091ad8b
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&,
clang::Parser::ParsingDeclRAIIObject*) + 4251
12 clang 0x000000000091dbfc
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, unsigned int,
clang::Decl*) + 1804
13 clang 0x000000000091f48d
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext) + 3277
14 clang 0x000000000090884c
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext,
llvm::SmallVector<clang::Parser::LateParsedAttribute*, 2u>*) + 3244
15 clang 0x00000000008f42b2
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&,
clang::AccessSpecifier) + 98
16 clang 0x00000000008f485e
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&,
clang::AccessSpecifier) + 766
17 clang 0x00000000008f9754
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::Parser::ParsingDeclSpec*) + 1988
18 clang 0x00000000008f9c70
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 192
19 clang 0x00000000008f2d5d clang::ParseAST(clang::Sema&, bool, bool)
+ 301
20 clang 0x000000000078cab4 clang::CodeGenAction::ExecuteAction() +
68
21 clang 0x000000000063dbd1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 337
22 clang 0x0000000000627444
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1348
23 clang 0x000000000061c9b8 cc1_main(char const**, char const**, char
const*, void*) + 904
24 clang 0x0000000000626217 main + 7143
25 libc.so.6 0x0000003ccee1ecdd __libc_start_main + 253
26 clang 0x000000000061adc9
Stack dump:
0. Program arguments: /usr/local/stow/llvm/llvm-3.1/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
a.cpp -mrelocation-model static -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.20.51.0.2 -momit-leaf-frame-pointer -coverage-file a.o -resource-dir
/usr/local/stow/llvm/llvm-3.1/bin/../lib/clang/3.1 -fmodule-cache-path
/var/tmp/clang-module-cache -internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/stow/llvm/llvm-3.1/bin/../lib/clang/3.1/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/bradshaw
-ferror-limit 19 -fmessage-length 155 -mstackrealign -fgnu-runtime
-fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
a.o -x c++ a.cpp
1. a.cpp:9:8: current parser token ';'
2. a.cpp:7:1: parsing struct/union/class body 'U'
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang: note: diagnostic msg: Please submit a bug report to
http://llvm.org/bugs/ and include command line arguments and all diagnostic
information.
clang: note: diagnostic msg: Preprocessed source(s) and associated run
script(s) are located at:
clang: note: diagnostic msg: /tmp/a-csnoHk.ii
clang: note: diagnostic msg: /tmp/a-csnoHk.sh
The output from clang 3.2 on OS X 10.8.4 is:
0 clang 0x0000000100c57bb2 main + 12932498
Stack dump:
0. Program arguments: /usr/bin/clang -cc1 -triple x86_64-apple-macosx10.8.0
-emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name
a.cpp -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu
core2 -target-linker-version 136 -coverage-file /Users/mjbshaw/a.o
-resource-dir /usr/bin/../lib/clang/4.2 -fmodule-cache-path
/var/folders/wp/h2zyzx516579b5q03sw4xrq00000gn/T/clang-module-cache
-stdlib=libc++ -std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/Users/mjbshaw -ferror-limit 19 -fmessage-length 138 -stack-protector 1
-mstackrealign -fblocks -fobjc-runtime=macosx-10.8.0
-fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
a.o -x c++ a.cpp
1. a.cpp:9:8: current parser token ';'
2. a.cpp:7:1: parsing struct/union/class body 'U'
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://developer.apple.com/bugreporter/ 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:
/var/folders/wp/h2zyzx516579b5q03sw4xrq00000gn/T/a-uWJgDJ.cpp
clang: note: diagnostic msg:
/var/folders/wp/h2zyzx516579b5q03sw4xrq00000gn/T/a-uWJgDJ.sh
clang: note: diagnostic msg:
********************
For comparison, this compiles fine with gcc-4.8.1: http://ideone.com/qjG5gp
Preprocessed source file for clang 3.1 (on Linux) (/tmp/a-csnoHk.ii):
# 1 "a.cpp"
# 1 "a.cpp" 1
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 156 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "a.cpp" 2
struct S
{
int x;
int& y = x;
};
union U
{
S s;
};
Run script file for clang 3.1 (on Linux) (/tmp/a-csnoHk.sh):
"/usr/local/stow/llvm/llvm-3.1/bin/clang" -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
a.cpp -mrelocation-model static -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.20.51.0.2 -momit-leaf-frame-pointer -coverage-file a.o -resource-dir
/usr/local/stow/llvm/llvm-3.1/bin/../lib/clang/3.1 -fmodule-cache-path
/var/tmp/clang-module-cache -internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/stow/llvm/llvm-3.1/bin/../lib/clang/3.1/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/bradshaw
-ferror-limit 19 -fmessage-length 155 -mstackrealign -fgnu-runtime
-fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
a.o -x c++ a.cpp
Preprocessed source file for clang 3.2 (on OS X)
(/var/folders/wp/h2zyzx516579b5q03sw4xrq00000gn/T/a-uWJgDJ.cpp):
# 1 "a.cpp" 1
struct S
{
int x;
int& y = x;
};
union U
{
S s;
};
Run script for clang 3.2 (on OS X)
(/var/folders/wp/h2zyzx516579b5q03sw4xrq00000gn/T/a-uWJgDJ.sh):
/usr/bin/clang -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all
-disable-free -disable-llvm-verifier -main-file-name a.cpp -pic-level 2
-mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2
-target-linker-version 136 -stdlib=libc++ -std=c++11 -fdeprecated-macro
-ferror-limit 19 -fmessage-length 138 -stack-protector 1 -mstackrealign
-fblocks -fobjc-runtime=macosx-10.8.0 -fobjc-dispatch-method=mixed
-fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -x c++ a-uWJgDJ.cpp
--
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/20130829/0ff8de13/attachment.html>
More information about the llvm-bugs
mailing list