http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57034
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-04-23 11:59:35 UTC --- Guess you should read something about floating point. 0x7fffffff of course can't be represented exactly in IEEE 754 single precision format, so when you convert 2147483647 to float, you get 2147483648.0f (1 higher than that), and that doesn't fit into int range, so [conv.fpint]/1 applies and it is undefined behavior. IEEE 754 double precision format has bigger mantissa, so if you convert 2147483647 to double, you get 2147483647.0 and can convert it back to int, but if you try the same with long long maximum, it won't work again.