Hacker News new | past | comments | ask | show | jobs | submit login

DR 109 allows that a program may be strictly conforming even if some possible executions of the program invoke UB:

> A conforming implementation must not fail to translate a strictly conforming program simply because some possible execution of that program would result in undefined behavior.

This text specifically allows for the case that a program is strictly conforming even if there is a possible execution that invokes UB. If a program is strictly conforming, it must produce the correct behavior.

I would challenge you to show an example where GCC or Clang will break the correctness of a program on account of UB that is not reached during program execution.

Here is an example where GCC and Clang specifically respects the correctness of a program as long as it does not reach the UB: https://godbolt.org/z/befWah77W




It seems that you may be correct.

At the very least I am unable to construct a counter-example so I concede this point




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: