This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Warning for different pointer signedness
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Paul Schlie <schlie at comcast dot net>,Andrew Pinski <pinskia at physics dot uc dot edu>, gcc at gcc dot gnu dot org
- Date: Mon, 20 Dec 2004 14:44:08 -0800
- Subject: Re: Warning for different pointer signedness
- References: <BDECA48D.8502%schlie@comcast.net> <m3acs8vf6l.fsf@uniton.integrable-solutions.net>
On Mon, Dec 20, 2004 at 10:21:38PM +0100, Gabriel Dos Reis wrote:
> Pointers-to-object comparaison make sense (from the relevant standards
> point of view) only if they
>
> (i) point into the same object; or
> (ii) are (or one of them is) one-past-the-end of the same object; or
> (iii) are (or one of them is) null.
>
> You then realize that if the pointers are not of the same type or cannot be
> implicitly converted to each other, then the comparison become
> invalid.
But there is the interesting fact that pointers that differ only in
the signed-ness of the pointed-to object can alias each other. That
seems to imply that testing for equality makes sense, even without casting.