[llvm-bugs] [Bug 36966] New: Remove the statement about UB from fptrunc langref

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 31 07:26:32 PDT 2018


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

            Bug ID: 36966
           Summary: Remove the statement about UB from fptrunc langref
           Product: new-bugs
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: simonas+llvm.org at kazlauskas.me
                CC: llvm-bugs at lists.llvm.org

The Language Reference states that fptrunc (1) has an undefined result "if the
value cannot fit within the destination type" and (2) has "undefined" rounding
mode. This is quite worrying for frontends that want to avoid UB or even just
reliably provide ties-to-even truncation. Furthermore, there does not seem to
be any reason for fptrunc to be so undefined. By the assumption about the
default floating point environment (also in the Language Reference):

1. the rounding mode is ties-to-even everywhere, this should apply to fptrunc
as well

2. no floating-point exception state is maintained, i.e., the overflow
exception signaled if the value does not fit in the destination type can't be
inspected and is handled in the default way, which gives an infinite result as
one would expect

As far as I can tell, fixing this just requires a clarification in the Language
Reference. APFloat already does the right thing, and none of the in-tree passes
seem to make any attempt to exploit this nominal source of undefs.

-- 
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/20180331/0b7ba8f0/attachment.html>


More information about the llvm-bugs mailing list