[LLVMbugs] [Bug 21130] gvn badly replaces a call to fptosi
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Oct 2 10:51:35 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=21130
Sanjay Patel <spatel+llvm at rotateright.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |spatel+llvm at rotateright.com
Resolution|--- |INVALID
--- Comment #3 from Sanjay Patel <spatel+llvm at rotateright.com> ---
Both the LLVM Language Ref and the C standard (annex F.4) say that the code is
undefined, so anything goes:
fptosi:
"If the value won’t fit in the integer type, the results are undefined."
C - floating to integer conversion:
"...if the integral part of the floating value exceeds the range of the integer
type, then the "invalid" floating-point exception is raised and the resulting
value is unspecified."
Try using lrint()?
Clang does issue warnings when it's obvious that there's a conversion problem:
$ cat 21130.c
char foo() { return 156.0; }
$ ./clang 21130.c -c
21130.c:3:12: warning: implicit conversion from 'double' to 'char' changes
value from 156 to 127 [-Wliteral-conversion]
return 156.0;
~~~~~~ ^~~~~
1 warning generated.
...but your C test case is probably too complicated for that check.
--
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/20141002/9ba8556a/attachment.html>
More information about the llvm-bugs
mailing list