David Laight <david%l8s.co.uk@localhost> writes: > On Sun, Mar 13, 2011 at 07:40:45AM +0000, matthew green wrote: >> src/lib/libc/gen: unvis.c >> >> Log Message: >> cast "~0" to (size_t) when passing to a size_t taking function. >> fixes lint build errors. > > Is that right? My C promotion rules are getting rusty... > ~0 is of type 'int', 'size_t' is an unsigned type, if 'size_t' is > larger than 'int' isn't the convertion 'value preserving' rather > than 'sign preserving'? > So you need ~(size_t)0 if you want to generate the all 1's bit pattern? That sounds right to me, and if all-1s size_t means something, perhaps there should be a #define.
Attachment:
pgpLLzCeXxlcm.pgp
Description: PGP signature