On Tue, Sep 09, 2025 at 06:08:12PM +0300, Ville Voutilainen wrote: > The fail() can fall through when the contracts are evaluated in the > "observe" evaluation mode. > In that case it's not an actual "fail", it will call the contract > violation handler and return from that. > > And then the concern is that that call may be completely elided > because what follows is > UB in the form of the pointer dereference.
IMHO a correct compiler can't do that. Because the contract violation handler could have validly exit (0) or for (;;) ; etc. in it, so the UB wouldn't encountered in the program and so it would be valid. Jakub