[Bug c/27214] The C frontend introduces undefined pointer overflow

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Apr 19 15:31:00 GMT 2006



------- Comment #4 from rguenth at gcc dot gnu dot org  2006-04-19 15:31 -------
How's that "the same"?  Either you say that pointers follow unsigned integer
types in overflow behavior (quote me the standard for that) or explain why

     p + -4  is treated as  p + (char *)-4

but  p -  4  is treated as  p - (char *)4

which are different in overflow behavior as (char *) is "unsigned" as far as
the middle-end concerns.

I see 6.5.6/8 where it says

If both the pointer operand and the result point to elements of the same array
object, or one past the last element of the array object, the evaluation shall
not produce an overflow; otherwise, the behavior is undefined.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27214



More information about the Gcc-bugs mailing list