c/10226: unsigned short promotion with bitwise inversion

mmarks@internetmachines.com mmarks@internetmachines.com
Wed Mar 26 19:25:00 GMT 2003


>Number:         10226
>Category:       c
>Synopsis:       unsigned short promotion with bitwise inversion
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 26 18:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     mmarks@internetmachines.com
>Release:        unknown-1.0
>Organization:
>Environment:
gcc 3.2.1 and 3.2.2
>Description:
When two unsigned shorts (16 bit) variables are compared with one being inverted the comparison will fail.
The following code should pass, while it does generate a warning it should instead just work.

   unsigned short A = 0xDEAD;
   unsigned short B;
   B = ~A;
   if ( B == ~A) {
      printf("Pass\n");
   }
   else {
      printf("Fail\n");
   }

It compares 0xFFFFDEAD == 0x0000DEAD which fails
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list