https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82223
--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> --- (float)INT_MAX gets rounded to 2^31. When you try to convert it to int, it doesn't fit, so the compiler is at liberty to return INT_MAX if it likes. clang's -fsanitize=undefined does complain on your code (not gcc's though).