On Donnerstag, 21. März 2019 23:31:48 CET Jakub Jelinek wrote: > On Thu, Mar 21, 2019 at 11:19:54PM +0100, Allan Sandfeld Jensen wrote: > > Hmm, I am curious. How strongly would gcc assume x is 0? > > If x is not 0, then it is undefined behavior and anything can happen, > so yes, it can assume x is 0, sometimes gcc does that, sometimes not, > it is not required to do that. > > > From having fixed UBSAN warnings, I have seen many cases where undefined > > behavior was performed, but where the code was aware of it and the final > > Any program where it printed something (talking about -fsanitize=undefined, > not the few sanitizers that go beyond what is required by the language) > is undefined, period. It can happen to "work" as some users expect, it can > crash, it can format your disk or anything else. There is no well defined > after a process runs into UB. > That's nonsense and you know it. There are plenty of things that are undefined by the C standard that we rely on anyway.
But getting back to the question, well GCC carry such information further, and thus break code that is otherwise correct behaving on all known architectures, just because the C standard hasn't decided on one of two possible results? 'Allan