Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 33690 - Pointer comparisons skipped in execution
Pointer comparisons skipped in execution
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2001-03-28 16:51 EST by Need Real Name
Modified: 2007-04-18 12:32 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-03-30 02:52:27 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2001-03-28 16:51:22 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0; NAI IE4 
Build 4)

Given this code sample:

   #define HKEY_CLASSES_ROOT ((void *)0x80000000)
   #define HKEY_DYN_DATA     ((void *)0x80000005)
   void *hKey =              ((void *)0x80000001);
      printf("In range\n");
      printf("Out of range\n");
   printf("Low: %u High: %u hKey: %u\n",
          (unsigned long)H_KEY_CLASSES_ROOT,
          (unsigned long)H_KEY_DYN_DATA,
          (unsigned long)hKey);

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)
      printf("In range\n");

Reproducible: Always
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.

Comment 1 Jakub Jelinek 2001-03-29 15:37:09 EST
Verified both in gcc-2.96-80 and gcc-3_0-branch plus gcc-3_1-branch.
Comment 2 Jakub Jelinek 2001-03-29 16:48:03 EST
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
Comment 3 Jakub Jelinek 2001-03-30 02:52:23 EST
FYI, the patch is at http://gcc.gnu.org/ml/gcc-patches/2001-03/msg01977.html

Note You need to log in before you can comment on or make changes to this bug.