This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53707] compiler generates wrong code
- From: "galtgendo at o2 dot pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 02 Jul 2012 19:38:29 +0000
- Subject: [Bug c++/53707] compiler generates wrong code
- Auto-submitted: auto-generated
- References: <bug-53707-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53707
--- Comment #11 from RafaÅ MuÅyÅo <galtgendo at o2 dot pl> 2012-07-02 19:38:29 UTC ---
OK, I don't know if it's related, but
https://bugs.gentoo.org/show_bug.cgi?id=424475
and its follow-up
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11845
This code:
int
find_stack_direction ()
{
static char *addr = 0;
auto char dummy;
if (addr == 0)
{
addr = &dummy;
return find_stack_direction ();
}
else
return (&dummy > addr) ? 1 : -1;
}
int
main ()
{
return find_stack_direction () < 0;
}
works with '-O2' and gcc 4.6.3, breaks on the same compiler with '-O3'
works with both '-O2' and '-O3' on 4.7.1.
On an interesting note, it works with both '-O2' and '-O3' on 4.5.3 too.