Talk:Integer overflow: Difference between revisions

Content deleted Content added
Line 92:
:I might agree that the previous one isn't perfect, but recent discussions of C compilers indicate that it is needed, in some form or other. c optimizers have been doing things that I wouldn't suggest for some time. I disagree with this one, too, but it seems that they are doing it. [[User:Gah4|Gah4]] ([[User talk:Gah4|talk]]) 05:11, 12 September 2023 (UTC)
:: Sorry, I can't understand your comment. What exactly are compilers doing, and what evidence can you offer? [[User:Zero0000|Zero]]<sup><small>[[User_talk:Zero0000|talk]]</small></sup> 12:58, 12 September 2023 (UTC)
:: Incidentally, I know of some things that look somewhat similar but are actually not. For example, "if (x + 2 > x) ''something''" can be optimized to "''something''". It is valid because if no overflow occurs then the test is true arithmetically, and if there is overflow the result of the test is up to the implementation so treating it as true is allowed. A number of such gotchas are known. My example "z = x + y; if (z < 0) ''something''" is not like that. Although the result of "z = x + y" is implementation-defined if it overflows, the meaning of "if (z < 0) ''something''" is perfectly well defined. If execution flow reaches the statement "if (z < 0) ''something''" with z < 0 but ''something'' is not evaluated, that's a bug. [[User:Zero0000|Zero]]<sup><small>[[User_talk:Zero0000|talk]]</small></sup> 13:53, 12 September 2023 (UTC)