signed vs unsigned pointer warning

Dave Korn dk@artimi.com
Thu Sep 23 12:29:00 GMT 2004


> -----Original Message-----
> From: Andreas Schwab 
> Sent: 22 September 2004 22:57
> To: Dave Korn
> Cc: 'Morten Welinder'; gcc
> Subject: Re: signed vs unsigned pointer warning
> 
> "Dave Korn" writes:
> 
> > Which I don't think you can, since you can't store negative numbers
> > in an unsigned type. 
> 
> Actually you can, due to the modulo behaviour of unsigned integers.
> 
> Andreas.


  Well, yes, it is physically possible, but it's a kind of type-punning, it
defies the aliasing rules, and we get into some very deeply
language-lawyerly issues here, but it's not a valid representation IIUIC and
therefore invokes undefined behaviour in many circumstances.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....



More information about the Gcc mailing list