[LLVMbugs] [Bug 17686] New: static_casting a large unsigned long long to a double causes an FPE

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 24 09:46:28 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=17686

            Bug ID: 17686
           Summary: static_casting a large unsigned long long to a double
                    causes an FPE
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: brunner6 at llnl.gov
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11422
  --> http://llvm.org/bugs/attachment.cgi?id=11422&action=edit
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131024/a17ecec5/attachment.html>


More information about the llvm-bugs mailing list