[Bug sanitizer/118972] New: Missing ubsan complaint for double->int cast overflow
blubban at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Feb 21 13:15:53 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118972
Bug ID: 118972
Summary: Missing ubsan complaint for double->int cast overflow
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: blubban at gmail dot com
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
Target Milestone: ---
int main()
{
double max = __DBL_MAX__;
__builtin_printf("%x\n", (int)(double)max);
__builtin_printf("%x\n", (int)(double)__DBL_MAX__);
}
-O0 -fsanitize=undefined -Wall -Wextra
Expected: Two UBSan complaints or compiler warnings. Or, if GCC defines some
particular semantics for overflowing double->int casts, at least return the
same number for both.
Actual:
80000000
7fffffff
Clang's UBSan complains about both, as expected (then returns different
numbers, but that's fine, it's UB). https://godbolt.org/z/8rK7co19s
More information about the Gcc-bugs
mailing list