This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

Re: Patch for locale/programs/3level.h


On Mon, Aug 06, 2001 at 10:25:39PM +0200, Bruno Haible wrote:
> > We noticed a problem with ~0 nesting in 3level.h.  The following looks
> > more sane to me.
> >
> > -      if (lookup1 != ~((uint32_t) 0))
> > +      if (lookup1 != (uint32_t) ~0)
> 
> The values are not the same. If someone were to use this code with a
> compiler that has 'int' == 'int16_t' (which is not too far away, it
> was long time the default for some m68k gcc ports), the values are
> 
>              ~((uint32_t) 0) = 0xFFFFFFFF
>              (uint32_t) ~0   = 0x0000FFFF
> 
> The first value is definitely the intended one.
> 
> Therefore the code is more robust and portable as it is.

Just could miss some () here and there...
if (lookup1 != ~(uint32_t) 0)
should work equally well and be more readable.

	Jakub


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