[PATCH] Fix PR26763, pointer overflow

Roger Sayle roger@eyesopen.com
Mon Apr 3 14:52:00 GMT 2006


On Mon, 3 Apr 2006, Richard Guenther wrote:
> 2006-04-03  Richard Guenther  <rguenther@suse.de>
>
> 	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.


Roger
--



More information about the Gcc-patches mailing list