-
-
Save m-chaturvedi/673e9bd378b8b5ada02a377bbb3a5bc0 to your computer and use it in GitHub Desktop.
negative float to unsigned int
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat test_burkhard.cpp | |
int main() | |
{ | |
float f = -5.33; | |
unsigned int n = static_cast<unsigned int>(f); | |
return 0; | |
} | |
$ clang++ -fsanitize=undefined test_burkhard.cpp | |
$ ./a.out | |
test_burkhard.cpp:4:48: runtime error: -5.33 is outside the range of representable values of type 'unsigned int' | |
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test_burkhard.cpp:4:48 in | |
$ clang++ --version | |
clang version 11.0.0 (https://github.com/llvm/llvm-project.git 0160ad802e899c2922bc9b29564080c22eb0908c) | |
Target: x86_64-unknown-linux-gnu | |
Thread model: posix | |
InstalledDir: /home/chaturvedi/.linuxbrew/bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment