This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/34490] New: [4.3 Regression] r128833 causes miscompilation of glibc clock_gettime.c
- 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: 15 Dec 2007 23:04:22 -0000
- Subject: [Bug middle-end/34490] New: [4.3 Regression] r128833 causes miscompilation of glibc clock_gettime.c
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Following testcase distilled from x86_64 glibc clock_gettime.c is miscompiled
on the trunk since r128833. CSE1 removes all the c's return value checks
and assumes it wasn't small negative value:
extern void abort (void);
int (*fnp) (int, void *);
unsigned long bar (int, void *);
int
foo (int x, void *y)
{
long int b;
int (*c) (int, void *) = fnp;
if (c)
{
b = c (x, y);
if ((unsigned long) b < -4095L)
return b;
if (-b != 38)
goto lab;
}
unsigned long d = bar (x, y);
b = (long) d;
if ((unsigned long) b >= -4095L)
{
lab:
b = -1L;
}
return b;
}
int
__attribute__((noinline))
baz (int x, void *y)
{
return -x;
}
unsigned long
__attribute__((noinline))
bar (int x, void *y)
{
if (x != 38)
abort ();
return 0;
}
int
main (void)
{
fnp = baz;
if (foo (39, 0) != -1)
abort ();
if (foo (38, 0) != 0)
abort ();
return 0;
}
--
Summary: [4.3 Regression] r128833 causes miscompilation of glibc
clock_gettime.c
Product: gcc
Version: 4.3.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
GCC target triplet: x86_64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34490