[llvm-bugs] [Bug 46095] New: Clang can not detect runtime error of invalid float cast
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed May 27 02:40:51 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46095
Bug ID: 46095
Summary: Clang can not detect runtime error of invalid float
cast
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: haoxintu at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
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 (https://github.com/llvm/llvm-project
210616bd38d589020b45f8cbbf9f9ef1296f2729)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-clang/llvm-project/build/bin
--
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/20200527/d788525e/attachment.html>
More information about the llvm-bugs
mailing list