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: unassignedclangb...@nondot.org
Reporter: haoxi...@gmail.com
CC: blitzrak...@gmail.com, dgre...@apple.com,
erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs