This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/29695] New: [4.1/4.2/4.3 Regression] Folding breaks (a & 0x80) ? 0x80 : 0 for unsigned char or unsigned short a
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Nov 2006 11:23:58 -0000
- Subject: [Bug middle-end/29695] New: [4.1/4.2/4.3 Regression] Folding breaks (a & 0x80) ? 0x80 : 0 for unsigned char or unsigned short a
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
extern void abort (void);
int
f1 (void)
{
int a = 128;
return (a & 0x80) ? 0x80 : 0;
}
int
f2 (void)
{
unsigned char a = 128;
return (a & 0x80) ? 0x80 : 0;
}
int
main (void)
{
if (f1 () != 128)
abort ();
if (f2 () != 128)
abort ();
return 0;
}
f2 () is miscompiled with -O2 (on x86-64 and ppc at least), returns -128 rather
than 128.
--
Summary: [4.1/4.2/4.3 Regression] Folding breaks (a & 0x80) ?
0x80 : 0 for unsigned char or unsigned short a
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29695