Hello, On Tue, 9 Sep 2025, Ville Voutilainen wrote:
> > So the fear is that the violation handler for the first contract is (to > > the compiler) visibly no-op (side-effect-free), right? But then I have to > > ask what the author of the contract intended with the in(p) constraint > > when nothing is done when it fails? > > > > It would then be equivalent to just have written a single contract > > in(*p > 5). What would prevent the segfault in that case? > > For non-expert users, it's not a question of preventing the segfault, > but trying to keep some sort of logging operation intact in the program, > and not have that be optimized away, not even in the case of a > subsequent segfault. 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. Ciao, Michael.