This is the mail archive of the
mailing list for the glibc project.
Re: Patch for locale/programs/3level.h
- To: Bruno Haible <haible at ilog dot fr>
- Subject: Re: Patch for locale/programs/3level.h
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Mon, 6 Aug 2001 22:36:16 +0200
- Cc: libc-alpha at sources dot redhat dot com, Andreas Jaeger <aj at suse dot de>
- References: <email@example.com>
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
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.