bug with strict-aliasing for i[56]86
Greg McGary
greg@mcgary.org
Mon Aug 7 18:12:00 GMT 2000
The following test program loses for i586 and i686 with `-O1 -fstrict-aliasing'.
(It's OK for i386 and i486.)
The offending line is commented below.
`len' is garbage because it's allocated to a temporary on the stack,
but the store into the temporary is eliminated. (It seems to me that
there's no need to have the temporary, since `len' already resides on
the stack as an incoming arg.)
Greg
------------------------------------------------------------------------------
typedef struct charp { char *v, *l, *h; } charp;
typedef struct string { charp str; unsigned length; } string;
extern void
frob (charp s)
{
}
string
hack_string (unsigned len)
{
string ret;
frob (ret.str);
ret.length = len; /* ret.length gets garbage when i[56]86 and -fstrict-aliasing */
return ret;
}
int
main (void)
{
string s;
s = hack_string (10);
if (s.length != 10)
abort ();
return 0;
}
------------------------------------------------------------------------------
More information about the Gcc-bugs
mailing list