This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/10226: unsigned short promotion with bitwise inversion
- From: mmarks at internetmachines dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 26 Mar 2003 17:56:02 -0000
- Subject: c/10226: unsigned short promotion with bitwise inversion
- Reply-to: mmarks at internetmachines dot com
>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: