<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 --- - static_casting a large unsigned long long to a double causes an FPE"
href="http://llvm.org/bugs/show_bug.cgi?id=17686">17686</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>static_casting a large unsigned long long to a double causes an FPE
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</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>brunner6@llnl.gov
</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=11422" name="attach_11422" title="Sample code that causes an unexpected FPE">attachment 11422</a> <a href="attachment.cgi?id=11422&action=edit" title="Sample code that causes an unexpected FPE">[details]</a></span>
Sample code that causes an unexpected FPE
I am getting an FPE when converting a double to an unsigned long long, if the
double is larger than the max (signed) long long. It is as if the static_cast
code is using the signed integer internally, for the conversion from a double
to the int type, then preforms a second conversion from the signed to unsigned.
double x = 9.223372036854776e+18;
unsigned long long ullX = static_cast<unsigned long long>(x);
I've attached a full example that shows the problem when running clang-3.3 on
Linux. The code works various versions of gcc that I tried.</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>