This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
What makes this comparison always 0?
- From: Jason R Thorpe <thorpej at wasabisystems dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 25 Nov 2002 09:02:25 -0800
- Subject: What makes this comparison always 0?
- Organization: Wasabi Systems, Inc.
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>