This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: What makes this comparison always 0?
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: Jason R Thorpe <thorpej at wasabisystems dot com>, gcc at gcc dot gnu dot org
- Date: Mon, 25 Nov 2002 21:39:15 +0000
- Subject: Re: What makes this comparison always 0?
- References: <20021125170225.GA19290@yeah-baby.shagadelic.org>
Jason R Thorpe wrote:-
> #define KS_GROUP_Dead 0xf801 /* not encoded in keysym */
> #define KS_GROUP_Ascii 0xf802 /* not encoded in keysym */
> #define KS_GROUP_Keycode 0xf803 /* not encoded in keysym */
>
> #define KS_GROUP(k) ((k) >= 0x0300 && (k) < 0x0370 ? KS_GROUP_Dead : \
> (((k) & 0xf000) == 0xe000 ? KS_GROUP_Keycode : \
> (((k) & 0xf800) == 0xf000 ? ((k) & 0xff00) : \
> KS_GROUP_Ascii)))
>
> int
> test(unsigned short k)
> {
> return (KS_GROUP(k) == KS_GROUP_Keycode);
> }
>
> --- snip ---
>
> ..the mainline currently reports the test is always 0:
>
> swinger:thorpej 5$ /usr/local/gnu/bin/gcc -O2 -c test.c
> test.c: In function `test':
> test.c:13: warning: comparison is always 0
>
> If I add a 'U' suffix to the KS_GROUP_Keycode constant, the warning does not
> appear.
>
> Is this a bug in GCC, or am I confused about the promotion/extension rules?
At a glance, it looks like a bug. Are you sure the comparison it's
talking about is not one of the ones in KS_GROUP? I can't see how it
could be any of the comparisons in sight, but still...
Neil.