public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21405] New: Template inlines have global visibility
@ 2005-05-05 21:49 mike at navi dot cx
  2005-05-05 22:27 ` [Bug c++/21405] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: mike at navi dot cx @ 2005-05-05 21:49 UTC (permalink / raw)
  To: gcc-bugs

See http://gcc.gnu.org/ml/libstdc++/2005-04/msg00173.html

If you have code like:

std::string b = "bee";
std::string c = "see";

std::string a = b + c;

Then the string + operator overload will appear in the final ELF image with
GLOBAL WEAK visibility, meaning it can be bound to the wrong version of the
symbol at runtime (ie symbol versioning is ignored).

This is serious as it means you can't mix libraries that use different C++ ABIs
into the same image even if they only interact via C ABIs, something that the
GCC docs explicitly say will work!

-- 
           Summary: Template inlines have global visibility
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mike at navi dot cx
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
@ 2005-05-05 22:27 ` pinskia at gcc dot gnu dot org
  2005-05-05 22:40 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-05 22:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-05 22:27 -------
I don't know if this is really a vaild bug, as the standard requires the inline function as the same so it 
would be undefined if they are different.

-- 


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
  2005-05-05 22:27 ` [Bug c++/21405] " pinskia at gcc dot gnu dot org
  2005-05-05 22:40 ` pinskia at gcc dot gnu dot org
@ 2005-05-05 22:40 ` mike at navi dot cx
  2005-05-06  0:17 ` mike at navi dot cx
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mike at navi dot cx @ 2005-05-05 22:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mike at navi dot cx  2005-05-05 22:39 -------
I don't understand what you mean. There's definitely a bug here because a
configuration that the docs say should work, causes mysterious crashes due to
mis-binds of symbols. I suspect building with -fvisibility-inlines-hidden can
resolve this problem but why is it not the default?

-- 


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
  2005-05-05 22:27 ` [Bug c++/21405] " pinskia at gcc dot gnu dot org
@ 2005-05-05 22:40 ` pinskia at gcc dot gnu dot org
  2005-05-05 22:40 ` mike at navi dot cx
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-05 22:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-05 22:40 -------
So here is the story really global templates have aways global visibility in C++ so this is not a bug in 
GCC or binutils.  This is a bug in how you think that you can use two different versions. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
                   ` (2 preceding siblings ...)
  2005-05-05 22:40 ` mike at navi dot cx
@ 2005-05-06  0:17 ` mike at navi dot cx
  2005-05-08 12:18 ` chris at bubblescope dot net
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mike at navi dot cx @ 2005-05-06  0:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mike at navi dot cx  2005-05-06 00:17 -------
No, there is very definitely a bug here even if it's just in the documentation.

The GCC docs say in very clear and unambiguous terms that this will work, by
design. Not by accident, by design. That's the whole point of applying symbol
versions to the standard C++ library.

It only affects methods that have been inlined into the headers. Methods that
are defined as external work correctly. So either:

a) No methods should be inlined

or

b) GCC should not emit them as GLOBAL WEAK so they can be overridden by other
definitions elsewhere in the image

The latter is what the new -fvisibility-inlines-hidden switch does. So why is it
not on by default?

-- 


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
                   ` (3 preceding siblings ...)
  2005-05-06  0:17 ` mike at navi dot cx
@ 2005-05-08 12:18 ` chris at bubblescope dot net
  2005-05-08 12:38 ` mike at navi dot cx
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: chris at bubblescope dot net @ 2005-05-08 12:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From chris at bubblescope dot net  2005-05-08 12:18 -------
Out of interest, where do the docs say that? (I'm not being sarcastic, just interested)

-- 


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
                   ` (4 preceding siblings ...)
  2005-05-08 12:18 ` chris at bubblescope dot net
@ 2005-05-08 12:38 ` mike at navi dot cx
  2005-05-25 23:24 ` [Bug libstdc++/21405] " bkoz at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mike at navi dot cx @ 2005-05-08 12:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mike at navi dot cx  2005-05-08 12:38 -------
http://gcc.gnu.org/onlinedocs/libstdc++/abi.html

See the "testing multi-abi binaries" section at the bottom:

<quote>

A "C" application, dynamically linked to two shared libraries, liba, libb. The
dependent library liba is C++ shared library compiled with gcc-3.3.x, and uses
io, exceptions, locale, etc. The dependent library libb is a C++ shared library
compiled with gcc-3.4.x, and also uses io, exceptions, locale, etc.

[ ... snip ... ]

This resulting binary, when executed, will be able to safely use code from both
liba, and the dependent libstdc++.so.6, and libb, with the dependent libstdc++.so.5.

</quote>

A C++ program linked indirectly (via a C library) against another C++ library is
exactly the same scenario. This is the whole point of symbol versioning.

-- 


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
                   ` (5 preceding siblings ...)
  2005-05-08 12:38 ` mike at navi dot cx
@ 2005-05-25 23:24 ` bkoz at gcc dot gnu dot org
  2005-05-31 13:37 ` mike at navi dot cx
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2005-05-25 23:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bkoz at gcc dot gnu dot org  2005-05-25 22:49 -------
Changing this to libstdc++, so we remember to track this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |libstdc++


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
                   ` (6 preceding siblings ...)
  2005-05-25 23:24 ` [Bug libstdc++/21405] " bkoz at gcc dot gnu dot org
@ 2005-05-31 13:37 ` mike at navi dot cx
  2005-05-31 15:29 ` giovannibajo at libero dot it
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mike at navi dot cx @ 2005-05-31 13:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mike at navi dot cx  2005-05-31 13:23 -------
Reopening the bug, as Benjamin wishes to track it.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
                   ` (7 preceding siblings ...)
  2005-05-31 13:37 ` mike at navi dot cx
@ 2005-05-31 15:29 ` giovannibajo at libero dot it
  2005-06-01 11:56 ` mike at navi dot cx
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2005-05-31 15:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2005-05-31 15:10 -------
You can't use -fvisibility-inlines-hidden or otherwise you'll get linker errors 
if the compiler later decides not to inline those functions. I don't think you 
can win.

-- 


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
                   ` (8 preceding siblings ...)
  2005-05-31 15:29 ` giovannibajo at libero dot it
@ 2005-06-01 11:56 ` mike at navi dot cx
  2005-06-03 22:02 ` adam at gimp dot org
  2005-08-02 14:28 ` matze at braunis dot de
  11 siblings, 0 replies; 13+ messages in thread
From: mike at navi dot cx @ 2005-06-01 11:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mike at navi dot cx  2005-06-01 11:56 -------
So this feature is basically terminally broken and never worked in the first place?

How about if GCC supported a new attribute or something that made it emit
inlines for that class with a specific symbol version?

-- 


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
                   ` (9 preceding siblings ...)
  2005-06-01 11:56 ` mike at navi dot cx
@ 2005-06-03 22:02 ` adam at gimp dot org
  2005-08-02 14:28 ` matze at braunis dot de
  11 siblings, 0 replies; 13+ messages in thread
From: adam at gimp dot org @ 2005-06-03 22:02 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adam at gimp dot org


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/21405] Template inlines have global visibility
  2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
                   ` (10 preceding siblings ...)
  2005-06-03 22:02 ` adam at gimp dot org
@ 2005-08-02 14:28 ` matze at braunis dot de
  11 siblings, 0 replies; 13+ messages in thread
From: matze at braunis dot de @ 2005-08-02 14:28 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matze at braunis dot de


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-08-02 14:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-05 21:49 [Bug c++/21405] New: Template inlines have global visibility mike at navi dot cx
2005-05-05 22:27 ` [Bug c++/21405] " pinskia at gcc dot gnu dot org
2005-05-05 22:40 ` pinskia at gcc dot gnu dot org
2005-05-05 22:40 ` mike at navi dot cx
2005-05-06  0:17 ` mike at navi dot cx
2005-05-08 12:18 ` chris at bubblescope dot net
2005-05-08 12:38 ` mike at navi dot cx
2005-05-25 23:24 ` [Bug libstdc++/21405] " bkoz at gcc dot gnu dot org
2005-05-31 13:37 ` mike at navi dot cx
2005-05-31 15:29 ` giovannibajo at libero dot it
2005-06-01 11:56 ` mike at navi dot cx
2005-06-03 22:02 ` adam at gimp dot org
2005-08-02 14:28 ` matze at braunis dot de

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).