This is the mail archive of the gcc@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: Warning for different pointer signedness


On Mon, Dec 20, 2004 at 11:14:58PM +0100, Gabriel Dos Reis wrote:
> Yes, that means they springle cast as approppriate, not that an
> implicit conversion on pointers is performed.
> 
> | So
> |     int foo (unsigned char *p) { return strcmp (p, "foo"); }
> | will always work correctly. But now the compiler emits an
> | unconditional warning.  This seems dubious to me.  The code is safe.
> 
> The code looks dubious to me, as in real life it would hardly pass
> code-review stage.

Sorry, Gaby, I don't buy this argument, given the C aliasing rules.
C says a pointer to unsigned T and a pointer to signed T can point to
the same object.  C specifies the meaning of the foo routine above.
There is no ambiguity with the code.  I think that we were right before,
when we warned about this code only when -pedantic was specified.
 


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