This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: What makes this comparison always 0?


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.


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