[llvm-bugs] [Bug 46095] Clang can not detect runtime error of invalid float cast

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 28 15:52:39 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46095

Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
This was an intentional change. Between Clang 8 and Clang 9, we changed the
range of representable values of floating-point types from [-max, +max] to
[-inf, +inf], so there is no longer any undefined behavior when converting
between floating-point types in Clang.

This is documented at
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks:

"""
-fsanitize=float-cast-overflow: Conversion to, from, or between floating-point
types which would overflow the destination. Because the range of representable
values for all floating-point types supported by Clang is [-inf, +inf], the
only cases detected are conversions from floating point to integer types.
"""

Converting 1e51 from double to float is valid since Clang 9, and produces +inf.
This is working as intended.

-- 
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/20200528/d9062680/attachment.html>


More information about the llvm-bugs mailing list