<html>
<head>
<base href="https://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 --- - Clang crashes when initializing out-of-order struct references"
href="https://llvm.org/bugs/show_bug.cgi?id=25755">25755</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang crashes when initializing out-of-order struct references
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.7
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>darin.tay@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Code below crashes clang 3.7 (also 3.5) on Ubuntu 14.04.
---
struct Test {
int& a;
int& b;
};
int main() {
int d = 0;
auto a = Test {
.b = d,
.a = d,
};
}
---
Compiled with "-std=c++11".
0 libLLVM-3.7.so.1 0x00007f70e95f2f08
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 56
1 libLLVM-3.7.so.1 0x00007f70e95f2369
2 libpthread.so.0 0x00007f70e7fcd340
3 clang 0x00000000011f7ee4
clang::ASTContext::getTypeInfoImpl(clang::Type const*) const + 660
4 clang 0x00000000011f05bf
clang::ASTContext::getTypeInfo(clang::Type const*) const + 127
5 clang 0x00000000011f7ae9
clang::ASTContext::getPreferredTypeAlign(clang::Type const*) const + 73
6 clang 0x00000000011fa13b
clang::ASTContext::getDeclAlign(clang::Decl const*, bool) const + 379
7 clang 0x000000000096f291
clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&) + 113
8 clang 0x000000000096fcd7
clang::CodeGen::CodeGenFunction::EmitAutoVarDecl(clang::VarDecl const&) + 23
9 clang 0x000000000089621f
clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) + 95
10 clang 0x00000000008a046f
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 127
11 clang 0x000000000089d01e
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 110
12 clang 0x000000000089d45f
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) + 79
13 clang 0x00000000008b9ac2
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*) + 178
14 clang 0x00000000008bfa8e
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 622
15 clang 0x00000000008d4738
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 408
16 clang 0x00000000008d5a18
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 344
17 clang 0x00000000008d81f0
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 1120
18 clang 0x00000000008d8c78
19 clang 0x0000000000868fe3
20 clang 0x000000000085aa2c
21 clang 0x0000000000a22926 clang::ParseAST(clang::Sema&, bool,
bool) + 310
22 clang 0x00000000006be956 clang::FrontendAction::Execute() + 438
23 clang 0x000000000069c8e8
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 280
24 clang 0x0000000000684f34
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1892
25 clang 0x000000000067ee08 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 2104
26 clang 0x000000000067cf63 main + 8963
27 libc.so.6 0x00007f70e76feec5 __libc_start_main + 245
28 clang 0x000000000067d7e4
Stack dump:
0. Program arguments: /usr/lib/llvm-3.7/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier
-main-file-name test.cc -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.24
-dwarf-column-info -resource-dir /usr/lib/llvm-3.7/bin/../lib/clang/3.7.1
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/llvm-3.7/bin/../lib/clang/3.7.1/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++11 -fdeprecated-macro
-fdebug-compilation-dir /home/dtay/src/new_stuff/c -ferror-limit 19
-fmessage-length 363 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/test-a1c8f9.o -x c++ test.cc
1. <eof> parser at end of file
2. test.cc:6:5: LLVM IR generation of declaration 'main'
3. test.cc:6:5: Generating code for declaration 'main'
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
Ubuntu clang version 3.7.1-svn253742-1~exp1 (branches/release_37) (based on
LLVM 3.7.1)
Target: x86_64-pc-linux-gnu
Thread model: posix
Putting the assignments in declared order (.a then .b) prevents it from
crashing.</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>