<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 asserts with -menable-unsafe-fp-math" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24141&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=RtIxaqxBQzxPzSZWII9pHljTO5ZBoLSKlhknmFqIQOM&s=eLVVCjE8VSNcQQKO99wCv0vLije5_LPdg8IA0uH-uRM&e=">24141</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang asserts with -menable-unsafe-fp-math
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</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>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rtrieu@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Reproduction:
struct pair {
double first;
double second;
pair() : first(0), second(0) {}
};
static pair ReturnPair(double x) {
double Dnext = 1 + (2) * x;
return pair();
}
void Run() {
double x = 0;
while (true) {
pair Q = ReturnPair(x);
double step = Q.first / Q.second;
x -= step;
}
}
Command line:
clang -cc1 -emit-obj -O1 -menable-unsafe-fp-math foo.cpp
Cause:
SelectionDAG::getNode is called with a null pointer for the N1 parameter, which
the function assumes is non-null. The actual assert is triggered inside
casting code when N1 is the argument to a dyn_cast.
Stack dump:
0. Program arguments: clang -cc1 -emit-obj -O1 -menable-unsafe-fp-math
foo.cpp
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'foo.cpp'.
4. Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z3Runv'
Aborted (core dumped)
clang: ../include/llvm/Support/Casting.h:81: static bool
llvm::isa_impl_cl<llvm::ConstantSDNode, llvm::SDNode *>::doit(const From *) [To
= llvm::ConstantSDNode, From = llvm::SDNode *]: Assertion `Val && "isa<> used
on a null pointer"' failed.
#0 0x16801ad llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/bin/clang-3.5+0x16801ad)
#1 0x16815bb SignalHandler(int) (/usr/local/bin/clang-3.5+0x16815bb)
#2 0x7f988f1c3340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#3 0x7f988e6efcc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#4 0x7f988e6f30d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#5 0x7f988e6e8b86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#6 0x7f988e6e8c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#7 0x1bc28ff llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc, llvm::EVT,
llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags const*)
(/usr/local/bin/clang-3.5+0x1bc28ff)
#8 0x1b3a474 (anonymous namespace)::DAGCombiner::visit(llvm::SDNode*)
(/usr/local/bin/clang-3.5+0x1b3a474)
#9 0x1b2186c (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*)
(/usr/local/bin/clang-3.5+0x1b2186c)
#10 0x1b20dcd llvm::SelectionDAG::Combine(llvm::CombineLevel,
llvm::AliasAnalysis&, llvm::CodeGenOpt::Level)
(/usr/local/bin/clang-3.5+0x1b20dcd)
#11 0x1c39a50 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/usr/local/bin/clang-3.5+0x1c39a50)
#12 0x1c392c8 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function
const&) (/usr/local/bin/clang-3.5+0x1c392c8)
#13 0x1c35fe4
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/bin/clang-3.5+0x1c35fe4)
#14 0xdb9b81 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/bin/clang-3.5+0xdb9b81)
#15 0x10b460c llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/usr/local/bin/clang-3.5+0x10b460c)
#16 0x1339fd4 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/bin/clang-3.5+0x1339fd4)
#17 0x133a20b llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/bin/clang-3.5+0x133a20b)
#18 0x133a6f5 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/bin/clang-3.5+0x133a6f5)
#19 0x177d725 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*) (/usr/local/bin/clang-3.5+0x177d725)
#20 0x1cf2965 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/bin/clang-3.5+0x1cf2965)
#21 0x201f703 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/bin/clang-3.5+0x201f703)
#22 0x1a4cef2 clang::FrontendAction::Execute()
(/usr/local/bin/clang-3.5+0x1a4cef2)
#23 0x1a1d07c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/bin/clang-3.5+0x1a1d07c)
#24 0x1ac5dfc clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/bin/clang-3.5+0x1ac5dfc)
#25 0x706394 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/bin/clang-3.5+0x706394)
#26 0x70512e main (/usr/local/bin/clang-3.5+0x70512e)
#27 0x7f988e6daec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#28 0x702173 _start (/usr/local/bin/clang-3.5+0x702173)</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>