Optimisations and undefined behaviour
Mon Nov 9 22:21:00 GMT 2015
On 2015-11-09 15:11:27 -0700, Jeff Law wrote:
> I feel it's best to err on the side of safety here -- given a function call,
> loops and the like, we have to consider the possibility that the statement
> which exhibits UB may not be executed. And until that statement is
> executed, we have no license to do anything weird.
BTW, the C standard says that a function may be interrupted by a
signal at any time. So, if some code that has a visible side effect
appears before an UB, the program may be interrupted between this
code and the UB so that the UB will not occur. Thus a compiler does
not have the license to remove such code with side effect.
Vincent LefÃ¨vre <email@example.com> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the Gcc-help