public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/107535] -fvisibility=hidden should not hide C++17 inline static variables
Date: Thu, 15 Jun 2023 11:07:55 +0000	[thread overview]
Message-ID: <bug-107535-4-RfmtiYGmWq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107535-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> kind-of a pilot error,

Yes, this seems to be exactly what the code asks for. If you compile the class
with hidden visibility, its static member isn't shared between libfoo.so and
the rest of the program.

I think this fixes it:
struct __attribute__ ((visibility ("default"))) Foo {static inline int s = 100;
};

> maybe we should diagnose those cases instead?

So warn that DumpLibFoo has global visibility but refers to a global variable
that's potentially reachable from outside the current library, but that the
global variable's visibility doesn't match? Or something else?

      parent reply	other threads:[~2023-06-15 11:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-05 12:38 [Bug c++/107535] New: Shouldn't -fvisibility=hidden hide C++17 inline static variables? junchao.zhang at gmail dot com
2022-11-07  7:00 ` [Bug c++/107535] -fvisibility=hidden should not hide C++17 inline static variables rguenth at gcc dot gnu.org
2023-06-15 11:07 ` redi at gcc dot gnu.org [this message]

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-107535-4-RfmtiYGmWq@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).