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]

What makes this comparison always 0?


For the following:

 --- snip ---

#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?

Thanks...

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>


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