From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26040 invoked by alias); 2 Jul 2012 20:00:50 -0000 Received: (qmail 26031 invoked by uid 22791); 2 Jul 2012 20:00:49 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Jul 2012 20:00:35 +0000 From: "mikpe at it dot uu.se" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53707] compiler generates wrong code Date: Mon, 02 Jul 2012 20:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mikpe at it dot uu.se X-Bugzilla-Status: WAITING X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-07/txt/msg00294.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53707 Mikael Pettersson changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mikpe at it dot uu.se --- Comment #12 from Mikael Pettersson 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.