On Tue, 9 Sept 2025 at 19:20, Michael Matz <[email protected]> wrote: > I see. Logging would be a side-effect that has to be retained. There is > no correct compiler that could validly elide such call to fail(). Again, > the argument is simple: the very act of logging (as any interaction with > the outside world) always has the potential to either stop indefinitely or > exit the program, thereby avoiding the UB. Such side-effect must be > carried out before the UB.
It remains non-obvious whether the C++ standard says that. With observable_checkpoint(), it becomes much clearer what the standard says, and what the guarantees are supposed to be for programs that 'invoke' it before running into UB. Yes, the adopted revision of P1494 says a part of that "interaction with the outside world", but is limited to adding the establishment of an observable checkpoint to the functions the standard specifies, and it can't really talk about i/o in general establishing such a checkpoint, I think, because it then becomes a question of what i/o is and how that is specified, sigh.
