public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "matz at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/32511] [4.4/4.5/4.6 regression] GCC rejects inline+weak function
Date: Mon, 10 Jan 2011 15:49:00 -0000	[thread overview]
Message-ID: <bug-32511-4-yKukas7Ih8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-32511-4@http.gcc.gnu.org/bugzilla/>

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

Michael Matz <matz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matz at gcc dot gnu.org

--- Comment #12 from Michael Matz <matz at gcc dot gnu.org> 2011-01-10 15:46:31 UTC ---
Jason: you're right that there are historically multiple uses of 'weak'.  
But they conflict with each other.  If we regard it to merely allow
equivalent definitions in several translation units, then we indeed
could inline those, and the error Richard implemented would be wrong.

_But_ we wouldn't be able to describe the usecase that I think is actually
the one intended by the weak attribute, certainly the one that is deduced
from its ELF meaning, namely to allow interposition of a different
strong definition that isn't necessarily equivalent.

For that latter definition we must disallow inlining.

IMO we can't simply choose the first definition because it's broader
than the second, and also because it goes against the ELF specification.

If you need some attribute that follows the first definition I think
it should not be named weak, but rather something like 'comdat'.
Allow inline expansion, but also allow replacement by other definitions.

For a Novell bug-report (I think it can't be accessed from the outside)
I wrote this opinion about the connection between attribute weak and
the several possibilities of describing visibility and inlining:

-----------------------------------
I would propose the following semantics:
a) an explicit visibility attribute takes precedence (hence if marked
   weak and hidden, the weakness is ignored), alternatively this
   should be a warning
b) otherwise the symbol doesn't have explicit visibility, in other
   words it inherits from command line or block pragmas:
   in that case an additional weak attribute should cancel the visibility,
   as if it has default visibility (that will have the effect of
   disabling inlining, amongst other things)

An explicit inline attribute on a weak function should generate a warning
or error.
-----------------------------------

To add your desired semantics:
c) a 'comdat' attribute is compatible with inlining and visibility
   declarations (explicit or implicit) provided that all definitions
   of that symbol are marked 'comdat' and all of them are semantically
   equivalent


  parent reply	other threads:[~2011-01-10 15:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-32511-4@http.gcc.gnu.org/bugzilla/>
2010-09-30 11:56 ` rguenth at gcc dot gnu.org
2010-09-30 19:17 ` jason at gcc dot gnu.org
2011-01-10 15:49 ` matz at gcc dot gnu.org [this message]
2011-01-10 15:53 ` rguenth at gcc dot gnu.org
2011-01-11 11:30 ` [Bug c/32511] [4.4/4.5 Regression] " rguenth at gcc dot gnu.org
2011-01-11 11:30 ` [Bug c/32511] [4.4/4.5/4.6 regression] " rguenth at gcc dot gnu.org
2012-01-12 20:25 ` [Bug c/32511] [4.4/4.5 Regression] " pinskia at gcc dot gnu.org
2012-03-13 15:02 ` [Bug c/32511] [4.5 " jakub at gcc dot gnu.org
2012-07-02  9:27 ` rguenth at gcc dot gnu.org
2007-06-26  5:30 [Bug c/32511] New: GCC inlines weak function sabre at nondot dot org
2010-07-12 13:46 ` [Bug c/32511] [4.4/4.5/4.6 regression] GCC rejects inline+weak function jason at gcc dot gnu dot 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-32511-4-yKukas7Ih8@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).