From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19320 invoked by alias); 12 May 2014 17:42:54 -0000 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 Received: (qmail 19247 invoked by uid 48); 12 May 2014 17:42:50 -0000 From: "bugdal at aerifal dot cx" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/61144] Invalid optimizations for extern vars with local weak definitions Date: Mon, 12 May 2014 17:42: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-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bugdal at aerifal dot cx X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg01051.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61144 --- Comment #12 from Rich Felker --- Furthermore, __builtin_constant_p(dummy) wrongly returns 1, even though dummy is modifiable externally via foo (assuming foo is not replaced by a strong definition elsewhere). Perhaps this should be filed as a separate bug since it's also user-visible, but I think the cause is the same. On the other hand, according to my tests on gcc.godbolt.org, the incorrect value for __builtin_constant_p predates the optimization bug. This could mean they're separate bugs, but I suspect the later changes that cause the optimization bug were "correct" except that they're using the wrong concept of "is this expression constant?" from the earlier bug.