On Thu, Sep 18, 2025 at 12:41 PM David Brown via Std-Discussion <std-discussion@lists.isocpp.org> wrote:
C and C++ are defined in terms of observable behaviour.
 
Yes, and the initial message in this thread is questioning exactly observable behavior - whether the program halts, is observable behavior even when there are no other side effects. If the program contains a loop which the programmer can formally prove to be infinite, then the programmer expects to observe that the program never completes. And if the compiler optimizes the whole loop away, this leads to observable behavior (halting) which is different from what is expected.

The fact that an infinite loop without side effects needs to be designated as UB to allow this optimization further demonstrates that the issue concerns observable behavior. If it wasn't observable, there would be nothing to define or explicitly leave undefined.

And so, the issue raised by the initial message is about the pros and cons of specifying that this observable behavior is undefined. I myself am not competent enough to have a definite opinion, but I wouldn't want the discussion to stray too far away and lose sight of this original question.