On Wed, 2005-02-16 at 16:49 +0100, Theodore Papadopoulo wrote:
> 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)....
The cast is to ensure that both operands of the PLUS_EXPR have
the same type.

I looked for a little while into fixing this by having a new
tree node (PLUS_POINTER_EXPR or whatever it was) which took a 
pointer and an integer.  The amount of work necessary to get
that going is mind-boggling.  I gave up.

jeff


Reply via email to