tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

foo = (unsigned)bar; (was Re: dhcpcd-4.0.0-alpha1 ready for review)



On Thursday 17 April 2008 21:47:25 David Laight wrote:
> On Thu, Apr 17, 2008 at 11:00:28AM +0100, Roy Marples wrote:
> > I've also changed all instances of my ctype calls I could find to cast to
> > unsigned.
>
> You do mean 'unsigned char' don't you ?

OK, this piqued my curiosity last night. What would this be expected to do

signed char bar;
unsigned char foo;
foo = (unsigned)bar;

IMO, only two things are possible here
1) type is preserved, so bar is correctly cast to an unsigned char
2) type is silently changed, so bar is incorrectly cast to an unsigned (and I 
guess) int

I can't find any documentation on this, so does anyone have any opinion that 
can hopefully be backed up with reference documentation?

Thanks

Roy


Home | Main Index | Thread Index | Old Index