https://llvm.org/bugs/show_bug.cgi?id=22873
Bug ID: 22873
Summary: X86_64 cast double to unsigned long long gets FPE
FE_INVALID in cvttsd2si for values > 2^63
Product: new-bugs
Version: 3.4
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Created attachment 14026
--> https://llvm.org/bugs/attachment.cgi?id=14026&action=edit
Small reproducer for FPE during cast fpe9.cc
With floating point exception handling enabled for FE_INVALID, casts of doubles
to unsigned long long with values between 2^64 and 2^63 generate a FPE when
compiled with clang++ 3.4 on x86_64 RedHat EL6 in cvttsd2si. Testcase runs
when compiled with g++ and icpc. G++ also uses cvttsd2si (Convert Scalar
Double-Precision Floating-Point Value to Signed Doubleword Integer with
Truncation) but does checks to detect numbers in that range and modifies them
before executing cvttsd2si.
These are the three key lines of the short attached testcase fpe9.cc:
feenableexcept(FE_INVALID);
volatile double x = 1.8e19;
unsigned long long llval = static_cast<unsigned long long>(x);
Here is how I reproduced with clang++ 3.4 on x86_64:
clang++ fpe9.cc
./a.out
About to do static_cast (cvttsd2si) that gets FPE FE_INVALID on x86_64
Floating exception (core dumped)
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs