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++/46097] Switch to warn of global variables in a C++ shared object
Date: Thu, 21 Oct 2010 15:28:00 -0000	[thread overview]
Message-ID: <20101021152800.9v6zlJujz3UaOSpzjcdTz_WxkdRDYA2EggGSrXyDDb4@z> (raw)
In-Reply-To: <bug-46097-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-21 15:28:05 UTC ---
I'm not on gcc-help, but I assume Alexey's looking at this report now ...

> I would expect that TWO different instances of the global variable would
> be created in TWO different shared libraries - maybe with name mangling.

No, the compiler can't just add random mangling to symbols, that would mean the
linker can't find symbols!

If you want those objects to be distinct, put them in distinct namespaces
(possibly anonymous namespaces) to disambiguate them, as mentioned at
http://gcc.gnu.org/faq.html#dso
Otherwise you have an ODR violation due to two definitions of the same object.


  parent reply	other threads:[~2010-10-21 15:28 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-20 14:35 [Bug c++/46097] New: " noloader at gmail dot com
2010-10-20 15:53 ` [Bug c++/46097] " redi at gcc dot gnu.org
2010-10-20 17:34 ` noloader at gmail dot com
2010-10-20 17:39 ` noloader at gmail dot com
2010-10-20 22:46 ` redi at gcc dot gnu.org
2010-10-20 22:48 ` redi at gcc dot gnu.org
2010-10-20 23:18 ` noloader at gmail dot com
2010-10-20 23:48 ` redi at gcc dot gnu.org
2010-10-21  2:01 ` noloader at gmail dot com
2010-10-21 15:04 ` noloader at gmail dot com
2010-10-21 15:17 ` redi at gcc dot gnu.org
2010-10-21 15:22 ` redi at gcc dot gnu.org
2010-10-21 15:28 ` redi at gcc dot gnu.org [this message]
2010-10-21 16:11 ` noloader at gmail dot com
2010-10-21 16:13 ` noloader at gmail dot com
2010-10-21 16:15 ` noloader at gmail dot com
2010-10-21 16:24 ` redi at gcc dot gnu.org
2010-10-21 17:00 ` noloader at gmail dot com
2010-10-21 17:37 ` noloader at gmail dot com
2010-10-21 18:41 ` redi at gcc dot gnu.org
2010-10-21 18:47 ` redi at gcc dot gnu.org
2010-10-21 18:50 ` noloader at gmail dot com
2010-10-21 18:54 ` pinskia at gcc dot gnu.org
2010-10-21 19:52 ` noloader at gmail dot com
2010-10-22  1:59 ` noloader at gmail dot com
2010-10-22  5:52 ` noloader at gmail dot com
2010-10-22  7:35 ` redi at gcc dot gnu.org
2010-10-22  7:38 ` noloader at gmail dot com
2010-10-22 19:49 ` noloader at gmail dot com
2010-10-22 20:37 ` redi at gcc dot gnu.org
2010-10-22 23:49 ` ian at airs dot com
2010-10-22 23:56 ` ian at airs dot com

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=20101021152800.9v6zlJujz3UaOSpzjcdTz_WxkdRDYA2EggGSrXyDDb4@z \
    --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).