<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Remove the statement about UB from fptrunc langref"
   href="https://bugs.llvm.org/show_bug.cgi?id=36966">36966</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Remove the statement about UB from fptrunc langref
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>simonas+llvm.org@kazlauskas.me
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>