This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Optimisations and undefined behaviour


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 <vincent@vinc17.net> - 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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]