This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix PR26763, pointer overflow
- From: Roger Sayle <roger at eyesopen dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org, <joseph at codesourcery dot com>
- Date: Mon, 3 Apr 2006 08:30:40 -0600 (MDT)
- Subject: Re: [PATCH] Fix PR26763, pointer overflow
On Mon, 3 Apr 2006, Richard Guenther wrote:
> 2006-04-03 Richard Guenther <firstname.lastname@example.org>
> PR tree-optimization/26763
> * fold-const.c (fold_comparison): Fold PTR + CST CMP PTR + CST
> only for EQ_EXPR and NE_EXPR.
> * gcc.dg/torture/pr26763-1.c: New testcase.
> * gcc.dg/torture/pr26763-2.c: Likewise.
Restricting this transformation to EQ_EXPR and NE_EXPR means that it
should move from fold_comparison (which is common to equality and
ordering operators), to the correct place in fold_binary. Perhaps
somewhere around line 10065?
My suspicion is that in order to move forward on pointer arithmetics,
GCC's middle-end will eventually need PTR_PLUS_EXPR and PTR_MINUS_EXPR
tree codes, which are distinct from PLUS_EXPR and MINUS_EXPR as the
types of their operands and result need not match. This would allows
offsets to be signed, but pointers to be treated like unsigned. It
also would help with induction variable selection, reassociation and
pointer tracking for those targets that need it.
Unfortunately, I think fixing this aspect of GCC's type system would
be a lot of work.