This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/10226: unsigned short promotion with bitwise inversion


>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 at internetmachines dot 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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]