<html>
<head>
<base href="http://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 --- - -ftrapping-math flag ignored in optimization"
href="http://llvm.org/bugs/show_bug.cgi?id=18673">18673</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-ftrapping-math flag ignored in optimization
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>p.vanhoof@oma.be
</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>Created <span class=""><a href="attachment.cgi?id=11978" name="attach_11978" title="the test case">attachment 11978</a> <a href="attachment.cgi?id=11978&action=edit" title="the test case">[details]</a></span>
the test case
I recently installed the clang 3.4 release (from source, downloaded from the
llvm download page) on my 64-bit openSUSE 13.1 system. When I compiled the code
I develop, I noticed that it crashed almost immediately on an FP exception. The
same code ran fine under clang 3.3. I could reduce the problem to the attached
program.
If you compile this program with
% clang++ -O2 -ftrapping-math bug.cc
% ./a.out
0
Floating exception
Compiling at a lower level gives the correct result:
% clang++ -O1 -ftrapping-math bug.cc
% ./a.out
0
1e+300
You need to supply the input value 0 on the command line to prevent the
compiler from pre-computing the result at compile time.
By inspecting the assembly, it appears that the compiler implements the
division more or less as
1./max(x,1.e-300) -> min(1./x,1e300)
However, such an optimization is not allowed when -ftrapping-math is in effect
since it will spuriously crash the program when x is zero.</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>