Warning for different pointer signedness

Joe Buck Joe.Buck@synopsys.COM
Mon Dec 20 22:47:00 GMT 2004


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.
 



More information about the Gcc mailing list