On Fri, May 18, 2012 at 11:13 PM, Robert Dewar <de...@adacore.com> wrote: > On 5/18/2012 4:27 PM, Ulrich Weigand wrote: > >> I finally got some time to look into this in detail. The various special- >> case transforms in associate_plusminus all transform a plus/minus >> expression >> tree into either a single operand, a negated operand, or a single plus or >> minus of two operands. This is valid as long as we can prove that the >> newly introduced expression can never overflow (if we're doing signed >> arithmetic). > > > It's interesting to note that for Ada, reassociatin is allowed if there > are no overriiding parens, even if it would introduce an overflow > (exception) that would not occur otherwise. However, I think I prefer > the C semantics!
So you mean in Ada signed types have undefined overflow for all possible associations of an expression wrapped in paranteses? That's certainly interesting ... especially how this is actually formally specified. Also interesting to think about how we could transfer this knowledge to the middle-end (in the context of the no-undefined-overflow branch where I merely dealt with the C way of -f[no-]wrapv of signed types). For Fortran we have PAREN_EXPR as association barrier, but that's of course not giving extra freedom to things inside. Richard.