https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66329
Bug ID: 66329
Summary: If condition evaluated wrongly for "y&1 == 0"
condition
Product: gcc
Version: 4.8.3
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: shimple0 at yahoo dot com
Target Milestone: ---
Created attachment 35649
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35649&action=edit
test code of sample runs
gcc (GCC) 4.8.3
Target: x86_64-pc-cygwin
$ g++ gcc-bug.cpp
$ ./a.exe
3
y:3, y&1=1
Testing with 'if (y&1 == 0)'
y&1 != 0
Testing with 'if (y&1 == 1)'
y&1 == 1
$ ./a.exe
2
y:2, y&1=0
Testing with 'if (y&1 == 0)'
y&1 != 0
Testing with 'if (y&1 == 1)'
y&1 != 1
Haven't tested it for other data types than int, unsigned int.
Haven't tested it with gcc, but this bug could be there as well.