<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 --- - Crash with Unhandled DeclRefExpr when using inline friend functions, templates, and member pointers"
href="https://llvm.org/bugs/show_bug.cgi?id=25848">25848</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Crash with Unhandled DeclRefExpr when using inline friend functions, templates, and member pointers
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>abbeyj@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>Created <span class=""><a href="attachment.cgi?id=15462" name="attach_15462" title="Preprocessed source">attachment 15462</a> <a href="attachment.cgi?id=15462&action=edit" title="Preprocessed source">[details]</a></span>
Preprocessed source
Compiling the following source crashes clang:
struct A;
typedef int A::* P;
inline P g();
template<P M>
struct R {
friend P g() {
return M;
}
};
void m() {
g();
}
I've tried to reduce the test case as much as possible. I'm using the latest
clang, built from the llvm.org git mirror. I can also reproduce with clang 3.4
and clang 3.5.
$ clang++ -c crash.cpp
Unhandled DeclRefExpr
UNREACHABLE executed at
/home/user/llvm/tools/clang/lib/CodeGen/CGExpr.cpp:2170!
#0 0x0a7688c3 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/user/llvm-obj/bin/clang-3.8+0xa7688c3)
#1 0x0a768bb4 PrintStackTraceSignalHandler(void*)
(/home/user/llvm-obj/bin/clang-3.8+0xa768bb4)
#2 0x0a767274 llvm::sys::RunSignalHandlers()
(/home/user/llvm-obj/bin/clang-3.8+0xa767274)
#3 0x0a768391 SignalHandler(int) (/home/user/llvm-obj/bin/clang-3.8+0xa768391)
0 clang-3.8 0x0a7688c3 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 50
1 clang-3.8 0x0a768bb4
2 clang-3.8 0x0a767274 llvm::sys::RunSignalHandlers() + 135
3 clang-3.8 0x0a768391
4 0xb77cb400 __kernel_sigreturn + 0
5 0xb77cb424 __kernel_vsyscall + 16
6 libc.so.6 0xb7482607 gsignal + 71
7 libc.so.6 0xb7485a33 abort + 323
8 clang-3.8 0x0a70e7cf
9 clang-3.8 0x0ab74ce9
clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) +
3651
10 clang-3.8 0x0ab6e321 clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr
const*) + 573
11 clang-3.8 0x0ab6dfb9
clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*,
clang::CodeGen::CodeGenFunction::TypeCheckKind) + 251
12 clang-3.8 0x0aba47b4
13 clang-3.8 0x0aba4a41
14 clang-3.8 0x0aba5333
15 clang-3.8 0x0abb6299
16 clang-3.8 0x0aba4cc4
17 clang-3.8 0x0abb4fe5
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 155
18 clang-3.8 0x0a97c28d
clang::CodeGen::CodeGenFunction::EmitReturnStmt(clang::ReturnStmt const&) + 749
19 clang-3.8 0x0a978e91 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*) + 885
20 clang-3.8 0x0a979764
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) + 86
21 clang-3.8 0x0a9ba57e
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*) + 124
22 clang-3.8 0x0a9bb047
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 2029
23 clang-3.8 0x0a9d33e2
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 582
24 clang-3.8 0x0a9cfd16
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 468
25 clang-3.8 0x0a9cdde0 clang::CodeGen::CodeGenModule::EmitDeferred() + 480
26 clang-3.8 0x0a9c9bd8 clang::CodeGen::CodeGenModule::Release() + 30
27 clang-3.8 0x0b0e3160
28 clang-3.8 0x0b0dd686
29 clang-3.8 0x0b80d613 clang::ParseAST(clang::Sema&, bool, bool) + 705
30 clang-3.8 0x0ad75247 clang::ASTFrontendAction::ExecuteAction() + 307
31 clang-3.8 0x0b0e0612 clang::CodeGenAction::ExecuteAction() + 2684
32 clang-3.8 0x0ad74d33 clang::FrontendAction::Execute() + 123
33 clang-3.8 0x0ad343bb
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1007
34 clang-3.8 0x0ae525e4
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1008
35 clang-3.8 0x08fee535 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) + 1032
36 clang-3.8 0x08fe5f5d
37 clang-3.8 0x08fe69ab main + 1998
38 libc.so.6 0xb746da83 __libc_start_main + 243
39 clang-3.8 0x08fe2801
Stack dump:
0. Program arguments: /home/user/llvm-obj/bin/clang-3.8 -cc1 -triple
i686-pc-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name crash.cpp
-mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu pentium4
-dwarf-column-info -coverage-file /home/user/uncallable/crash.cpp -resource-dir
/home/user/llvm-obj/bin/../lib/clang/3.8.0 -internal-isystem
/usr/lib/gcc/i686-linux-gnu/4.8/../../../../include/c++/4.8 -internal-isystem
/usr/lib/gcc/i686-linux-gnu/4.8/../../../../include/i386-linux-gnu/c++/4.8
-internal-isystem
/usr/lib/gcc/i686-linux-gnu/4.8/../../../../include/i386-linux-gnu/c++/4.8
-internal-isystem
/usr/lib/gcc/i686-linux-gnu/4.8/../../../../include/c++/4.8/backward
-internal-isystem /usr/local/include -internal-isystem
/home/user/llvm-obj/bin/../lib/clang/3.8.0/include -internal-externc-isystem
/usr/include/i386-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /home/user/uncallable -ferror-limit 19 -fmessage-length
236 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o crash.o -x c++ crash.cpp
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. crash.cpp:8:12: Generating code for declaration 'g'
clang-3.8: error: unable to execute command: Aborted
clang-3.8: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
f127756d39b2c79a43e6a77af52fdb9411e0263d) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
813f44a29fd0fd140127023222d0633e23783bcc)
Target: i686-pc-linux-gnu
Thread model: posix
InstalledDir: /home/user/llvm-obj/bin
clang-3.8: 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-3.8: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.8: note: diagnostic msg: /tmp/crash-b7f7a2.cpp
clang-3.8: note: diagnostic msg: /tmp/crash-b7f7a2.sh
clang-3.8: 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>