This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[egcs-19980608] Extremely serious comparison bug
- To: egcs-bugs at cygnus dot com
- Subject: [egcs-19980608] Extremely serious comparison bug
- From: Hyman Rosen <hymie at prolifics dot com>
- Date: Thu, 11 Jun 1998 16:44:01 -0400
The following code runs incorrectly and prints "FAILED!" when compiled
with -O, -O1, or -O2 on x86 Linux. The reason is this sequence of
instructions for the comparison:
movb (%ebx),%al
andb $111,%al
cmpl $2,%eax <---- This is wrong
/*----------------------------------------------------------------------------*/
struct fd
{
unsigned char a;
unsigned char b;
} f = { 5 };
struct fd *g() { return &f; }
int h() { return -1; }
int main(int c, char **v)
{
extern int printf(char *, ...);
struct fd *f = g();
f->b = h();
if (((f->a & 0x7f) & ~0x10) <= 2)
printf("FAILED!\n");
return 0;
}
/*----------------------------------------------------------------------------*/