Content deleted Content added
→Explanation for removal: There is a lot of discussion, I believe at least around gcc. |
|||
Line 93:
:: 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)
:::
:::I haven't followed it exactly, but I am pretty sure that there are plenty of sources. There is a lot of discussion, especially as programs fail. C has always had overflow undefined, as different processors do different things. But many people know what the common processors do, and assume that. Now they get surprised. The (x+2 > x) is the easy case, but there are many that are harder to see, and that compiler optimizers seem to find. [[User:Gah4|Gah4]] ([[User talk:Gah4|talk]]) 20:26, 12 September 2023 (UTC)
|