From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0; NAI IE4
Given this code sample:
#define HKEY_CLASSES_ROOT ((void *)0x80000000)
#define HKEY_DYN_DATA ((void *)0x80000005)
void *hKey = ((void *)0x80000001);
if (hKey>=HKEY_CLASSES_ROOT && hKey<=HKEY_DYN_DATA)
printf("Out of range\n");
printf("Low: %u High: %u hKey: %u\n",
The comparison is never even performed. It's skipped over in gdb and
the "else" automatically executes without performing the comparison.
This, however, works without a problem:
if ((unsigned long)hKey>=(unsigned long)HKEY_CLASSES_ROOT
&& (unsigned long)hKey<=(unsigned long)HKEY_DYN_DATA)
Steps to Reproduce:
1. Enter above code sample.
2. Compile (i.e. gcc sample.c -o sample -g -lc)
3. Execute sample.
Actual Results: A comparison that should have resulted in true, was
skipped in execution and assumed to have a false result.
Expected Results: The comparison would be performed and validly determine
true or false.
Verified both in gcc-2.96-80 and gcc-3_0-branch plus gcc-3_1-branch.
Fixed, the fix will appear in 2.96-81. I've mailed it to gcc-patches
too (but gcc.gnu.org is dead ATM, so I cannot provide URL to the
FYI, the patch is at http://gcc.gnu.org/ml/gcc-patches/2001-03/msg01977.html