public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jason at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-103310-4-iVtxljlYpZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103310-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103310

Jason Merrill <jason at gcc dot gnu.org> 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 <jason at gcc dot gnu.org> ---
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. 

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, have
the C++ front end set that for manifestly-constant-evaluated expressions, and
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.

  parent reply	other threads:[~2021-11-18 15:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17 22:01 [Bug middle-end/103310] New: " msebor at gcc dot gnu.org
2021-11-18  0:40 ` [Bug c/103310] " msebor at gcc dot gnu.org
2021-11-18 15:58 ` jason at gcc dot gnu.org [this message]
2021-12-01 18:24 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103310-4-iVtxljlYpZ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).