This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/53707] compiler generates wrong code


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53707

Mikael Pettersson <mikpe at it dot uu.se> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu.se

--- Comment #12 from Mikael Pettersson <mikpe at it dot uu.se> 2012-07-02 20:00:34 UTC ---
(In reply to comment #11)
> 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.

This one is not a C++ issue.  Please move it to a new PR.  I can reproduce it
with 4.6-20120629 on x86_64-linux, but not with 4.7-20120630 or 4.8-20120701.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]