From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B1C14385843F; Thu, 18 Nov 2021 15:58:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1C14385843F From: "jason at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/103310] null comparison with a weak symbol eliminated Date: Thu, 18 Nov 2021 15:58:04 +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: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jason at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: 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: bug_status everconfirmed cc cf_reconfirmed_on Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Nov 2021 15:58:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103310 Jason Merrill changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 CC| |jason at gcc dot gnu.org Last reconfirmed| |2021-11-18 --- Comment #2 from Jason Merrill --- The C++ front end rejects the testcase with "declared weak after used". We= set refuse_visibility_changes under fold's tree_single_nonzero_warnv_p.=20 Changing get_create to get in maybe_nonzero_address makes the C++ compiler accept the testcase, and properly test whether alias is null. This issue seems to go back to Honza's r5-3627, which changed symtab_node::= get to symtab_node::get_create in the code that became maybe_nonzero_address, so that we decide early whether a particular function is weak or not. This was done so that constant-evaluation could properly decide that the address of a function is non-null. But it's harmful when we do that for speculative folding; we should only return a definitive answer, and set refuse_visibility_changes, when a constant result is required. It seems we need a way to tell fold that we really want a constant value, h= ave the C++ front end set that for manifestly-constant-evaluated expressions, a= nd only use get_create in that case. But I also guess the issue that the C front end is both optimizing away the test and not setting refuse_visibility_changes is a C front end issue, that it's doing the optimization without involving fold.=