On Wed, 2005-02-16 at 14:25 +0100, Richard Guenther wrote: > On Wed, 16 Feb 2005, Paul Schlie wrote:
> Yes, of course, but it is the C frontent that is producing > &a + (int *)-4, not me. I'm just trying to work around this... > > In fact, it is c-common.c:2289 that does -4 -> (int *)-4 > conversion, but pointer_int_sum is already called with PLUS_EXPR. > build_unary_op unconditionally expands &x[y] to x+y, regardless > of the sign of y. Of course the standard says that they are equal. > But is &x[-1] == x + (int *)4*(int *)-1 ? From this follows that > we have no way to convert this back to &x[-1], as we loose the > sign information by the (int *) cast. Reading this thread, I keep wondering why this cast to an (int*). It should be a simple int no ?? If the intent is to have both operands of the PLUS to have the same type then it might be a counter-example for this rule (but I do understand that it would require specific patterns for pointer addition which is fairly stupid in general).... Now, I'm not sure I understand the premisses of the discussion: &a [-4U/4] from &a[-1] are not written the same but still refer to the same value since the overflow happens the same when multiplying (unsigned)(-4) by 4... so I do not really see where is the problem. Then, I must add that I do not know much about the compiler's internals...