This is the mail archive of the gcc-bugs@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]

[Bug target/81801] [PATCH] Difference of two pointers generates signed overflow


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81801

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |32bit target
          Component|c                           |target

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually it is worse than you think.  The problem is __PTRDIFF_TYPE__ is
defined incorrectly if pointers can span across the sign bit (32bit).  There is
whole thread about this on gcc@.  The C/C++ language defines ptrdiff_t as a
type which can be used two take a difference of any two valid pointers and get
a signed difference.

In the case here 0x8002000f-0x0001000f should actually return a signed integer
that represents the space between those two pointers.

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