<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 on x86_64-linux-gnu with message "Invalid constantexpr cast!""
href="https://llvm.org/bugs/show_bug.cgi?id=26687">26687</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang crashes on x86_64-linux-gnu with message "Invalid constantexpr cast!"
</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>All
</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>helloqirun@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>The current clang trunk crashes when compiling the following test case on
x86_64-linux-gnu in both 32-bit and 64-bit modes.
It might be a regression of 3.2.
$ clang-trunk -v
clang version 3.9.0 (trunk 261467)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation:
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0
Selected GCC installation:
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
$ clang-trunk abc.c
abc.c:2:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
fn1() { asm("" : "=t"(a) : "0u"(0)); }
^
abc.c:2:38: warning: control reaches end of non-void function [-Wreturn-type]
fn1() { asm("" : "=t"(a) : "0u"(0)); }
^
clang-3.9: /home/absozero/trunk/llvm/lib/IR/Constants.cpp:1535: static
llvm::Constant *llvm::ConstantExpr::getCast(unsigned int, llvm::Constant *,
llvm::Type *, bool): Assertion `CastInst::castIsValid(opc, C, Ty) && "Invalid
constantexpr cast!"' failed.
#0 0x0000000001843038 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1843038)
#1 0x00000000018414e6 llvm::sys::RunSignalHandlers()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x18414e6)
#2 0x000000000184374e SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x184374e)
#3 0x00007f2be48ad340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f2be3a5fcc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f2be3a630d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f2be3a58b86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f2be3a58c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x00000000013ea67c llvm::ConstantExpr::getCast(unsigned int,
llvm::Constant*, llvm::Type*, bool)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x13ea67c)
#9 0x00000000019b2c5b llvm::IRBuilder<true, llvm::ConstantFolder,
clang::CodeGen::CGBuilderInserter<true>
<span class="quote">>::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*,</span >
llvm::Twine const&) (/home/absozero/trunk/root-clang/bin/clang-3.9+0x19b2c5b)
#10 0x00000000019c1749
clang::CodeGen::CodeGenFunction::EmitAsmStmt(clang::AsmStmt const&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19c1749)
#11 0x00000000019c4f1b
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19c4f1b)
#12 0x00000000019efc18
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19efc18)
#13 0x0000000001a02cb3
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/home/absozero/trunk/root-clang/bin/clang-3.9+0x1a02cb3)
#14 0x00000000019feb73
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/home/absozero/trunk/root-clang/bin/clang-3.9+0x19feb73)
#15 0x0000000001a04b27
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1a04b27)
#16 0x000000000200947f (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x200947f)
#17 0x00000000020086f7
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x20086f7)
#18 0x00000000023a96e3 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x23a96e3)
#19 0x0000000001d2a5a5 clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1d2a5a5)
#20 0x0000000001cf5cb1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1cf5cb1)
#21 0x0000000001dbedbd
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1dbedbd)
#22 0x00000000007318e8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-3.9+0x7318e8)
#23 0x0000000000730416 main
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x730416)
#24 0x00007f2be3a4aec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#25 0x000000000072d2a5 _start
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x72d2a5)
Stack dump:
0. Program arguments: /home/absozero/trunk/root-clang/bin/clang-3.9 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name abc.c -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info
-debugger-tuning=gdb -resource-dir
/home/absozero/trunk/root-clang/bin/../lib/clang/3.9.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/bin/../lib/clang/3.9.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /home/absozero/projects/reduction/crash -ferror-limit
19 -fmessage-length 172 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/abc-05384f.o -x c abc.c
1. <eof> parser at end of file
2. abc.c:2:1: LLVM IR generation of declaration 'fn1'
3. abc.c:2:1: Generating code for declaration 'fn1'
clang-3.9: error: unable to execute command: Aborted (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 261467)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-3.9: 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.9: 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.9: note: diagnostic msg: /tmp/abc-f8a508.c
clang-3.9: note: diagnostic msg: /tmp/abc-f8a508.sh
clang-3.9: note: diagnostic msg:
********************
$ cat abc.c
double a;
fn1() { asm("" : "=t"(a) : "0u"(0)); }</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>