tst-malloc from glibc testsuite fails with 4.5.0 20100129, reporting "Error: errno is not set correctly". Examination of object files shows that gcc is assuming that "save" in the following is always zero. errno = 0; p = malloc (-1); save = errno;
errno is defined as (*__errno_location)() with extern int *__errno_location (void) __attribute__ ((__nothrow__)) __attribute__ ((__const__)); everything looks ok up until tst-malloc.c.065t.fre -- Summary: errno misoptimization due to __attribute__ ((__const__)) on __errno_location() Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: amodra at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42944