What makes this comparison always 0?

Jason R Thorpe thorpej@wasabisystems.com
Mon Nov 25 18:36:00 GMT 2002


On Mon, Nov 25, 2002 at 09:39:15PM +0000, Neil Booth wrote:

 > 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...

Yah, I'm not sure which comparison is actually failing.  Unforunately,
decomposing the statement makes the warning go away.

What's even more annoying is that it does NOT give a warning for:

#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 : \
                         KS_GROUP_Ascii)

int
test(unsigned short k)
{
  return (KS_GROUP(k) == KS_GROUP_Keycode);
}

...which, unless I am blind, is obviously aways false.  I wonder if a test
is inverted somewhere...

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



More information about the Gcc mailing list