This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR26763, pointer overflow


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
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]