https://bugs.llvm.org/show_bug.cgi?id=33448
Bug ID: 33448
Summary: static_cast<int16_t>(51200.0f) returns unpredictable
value
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangb...@nondot.org
Reporter: vi...@nethacker.com
CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
clang version 5.0.0 (trunk 304006)
Target: x86_64-unknown-linux-gnu
Thread model: posix
#include <iostream>
int main() {
std::cout << static_cast<int16_t>(51200) << std::endl;
std::cout << static_cast<int16_t>(51200.0f) << std::endl;
return 0;
}
$ clang++ -std=c++14 static_cast.cpp && ./a.out
-14336
12160
$ clang++ -std=c++11 static_cast.cpp && ./a.out
-14336
-16512
#include <iostream>
int main() {
std::cout << static_cast<int16_t>(51200.0f) << std::endl;
return 0;
}
$ clang++ -std=c++11 static_cast.cpp && ./a.out
2176
$ g++ -std=c++11 static_cast.cpp && ./a.out
32767
$ g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs