> > That's old code and the comment makes it quite clear why this is done > > though. > > Yeah, but then here "we don't need to evaluate it just for the check" > applies - the check is dead code as the outer comparison is always > false. I think what the code in the Ada frontend tries to achieve > is not actually what it does. Or the testcase is invalid (or rather > dependent on optimization performed).
I think that the testcase is valid (it is derived from a DEC Ada test written circa 1990). But, yes, the quoted gigi code wants to implement the famous 11.6 clause, whereby a check need not be raised if the expression is dead. The problem here is that the expression drives a conditional construct with side effects, so it cannot be considered as dead. In the end, the code indeed appears to be incorrect in resetting the flag. Instead the implementation of the 11.6 clause should rely purely on the optimizers and -fdelete-dead-exceptions. Thanks for your help to analyze this. -- Eric Botcazou