3 ms·
I would advise against making educated guesses about the result of overflow in the conversion from floating-point to integer: http://blog.frama-c.com/index.php
by pascal_cuoq 9y ago
I would advise against making educated guesses about the result of overflow in the conversion from floating-point to integer:
http://blog.frama-c.com/index.php?post/2013/10/09/Overflow-float-integer http://blog.frama-c.com/index.php?post/2013/10/09/Overflow-f...
Note: the optimization “Missed simplification of multiplication by integer-valued floating-point constant”, that the article points out that Clang does, relies on this kind of overflow to be undefined and causes yet more unpredictable results in some contexts. If you expect the “a *= 10.0;” statement to be translated to a float-to-int conversion instruction, you may expect the behavior of that instruction to apply on overflow, but it won't because the instruction won't have been generated at all.