This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/19068] New: Wrong code for MIN_EXPR and MAX_EXPR
- From: "steven at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Dec 2004 15:39:34 -0000
- Subject: [Bug middle-end/19068] New: Wrong code for MIN_EXPR and MAX_EXPR
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code miscompiles with all GCCs except mainline.
------------------------------------------------------
long fff[10];
extern "C" void abort (void);
long f(long a, long b)
{
int i;
a = *((long*)(a+5))>?*((long*)(a+1));
for(i=0;i<10;i++)
fff[i] = a;
}
int main(void)
{
int i;
long a[2] = {10,5};
f((long)(&a)-1,0);
for(i = 0;i<10;i++)
if (fff[i]!=10)
abort ();
}
------------------------------------------------------
The fix is the same as Roger Sayle's fix for PR18548.
--
Summary: Wrong code for MIN_EXPR and MAX_EXPR
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: steven at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org,roger at eyesopen dot
com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19068