<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 - Clang can not detect runtime error of invalid float cast"
   href="https://bugs.llvm.org/show_bug.cgi?id=46095">46095</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang can not detect runtime error of invalid float cast
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>haoxintu@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This case test.cc

#include<iostream>

int main(){
    double n = 10e50;
    float m = (float)n; // Error: 10e50 can't be represented as a float.
    std::cout << "ok" << std::endl;
    return 0;
}

$clang++-8 -w -fsanitize=float-cast-overflow test.cc ; ./a.out 
test.cc:5:22: runtime error: 1e+51 is outside the range of representable values
of type 'float'
ok

$clang++-9 -w -fsanitize=float-cast-overflow test.cc ; ./a.out 
ok

$clang++-10 -w -fsanitize=float-cast-overflow test.cc ; ./a.out 
ok

$clang++-trunk -w -fsanitize=float-cast-overflow test.cc ; ./a.out 
ok


My clang-trunk version is
$clang++-trunk --version
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
210616bd38d589020b45f8cbbf9f9ef1296f2729)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-clang/llvm-project/build/bin</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>