public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31903]  New: unwanted anonymous namespacing linkage
@ 2007-05-11 21:15 mrs at apple dot com
  2007-05-11 21:20 ` [Bug target/31903] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: mrs at apple dot com @ 2007-05-11 21:15 UTC (permalink / raw)
  To: gcc-bugs

It appears that 4.2 isn't making anonymous namespace variables unique (it's
also making them global). This is preventing LLVM from compiling with the 4.2
compiler.

$ cat foo.cpp
#include <typeinfo>

namespace {
  class foo {
   virtual void bar();
  };
}

void foo::bar() {}

#ifdef FOO
const std::type_info &X = typeid(foo);
#else
const std::type_info &Y = typeid(foo);
#endif

extern const std::type_info &X;

#ifndef FOO
int main() {}
#endif

$ g++-4.2 foo.cpp -c -o a.o
$ g++-4.2 foo.cpp -c -o b.o -DFOO
$ g++-4.2 a.o b.o
ld64-73.6 failed: duplicate symbol typeinfo for (anonymous namespace)::fooin
b.o and a.o


-- 
           Summary: unwanted anonymous namespacing linkage
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mrs at apple dot com
GCC target triplet: i686-apple-darwin9


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


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

* [Bug target/31903] unwanted anonymous namespacing linkage
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
@ 2007-05-11 21:20 ` pinskia at gcc dot gnu dot org
  2007-05-11 21:25 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-11 21:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-05-11 22:20 -------
This works correctly on i686-Linux-gnu in 4.2.0.


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

* [Bug target/31903] unwanted anonymous namespacing linkage
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
  2007-05-11 21:20 ` [Bug target/31903] " pinskia at gcc dot gnu dot org
@ 2007-05-11 21:25 ` pinskia at gcc dot gnu dot org
  2007-05-11 21:45 ` mrs at apple dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-11 21:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-05-11 22:25 -------
debian:~> ~/x86-local-fsf/bin/g++ -c -o t1.o t.cc
debian:~> ~/x86-local-fsf/bin/g++ -c -o t2.o t.cc -DFOO
debian:~> ~/x86-local-fsf/bin/g++ t1.o t2.o


-- 


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


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

* [Bug target/31903] unwanted anonymous namespacing linkage
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
  2007-05-11 21:20 ` [Bug target/31903] " pinskia at gcc dot gnu dot org
  2007-05-11 21:25 ` pinskia at gcc dot gnu dot org
@ 2007-05-11 21:45 ` mrs at apple dot com
  2007-05-11 21:55 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mrs at apple dot com @ 2007-05-11 21:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from mrs at apple dot com  2007-05-11 22:44 -------
I think this is a bug on Linux as well, though, I suspect it don't fail to
build, but rather I think it will compare the two typeinfo objects as equal
even though they are unrelated to each other.


-- 

mrs at apple dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrs at apple dot com


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


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

* [Bug target/31903] unwanted anonymous namespacing linkage
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
                   ` (2 preceding siblings ...)
  2007-05-11 21:45 ` mrs at apple dot com
@ 2007-05-11 21:55 ` pinskia at gcc dot gnu dot org
  2007-05-11 23:01 ` mrs at apple dot com
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-11 21:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-05-11 22:55 -------
(In reply to comment #3)
> I think this is a bug on Linux as well, though, I suspect it don't fail to
> build, but rather I think it will compare the two typeinfo objects as equal
> even though they are unrelated to each other.

Nope:
Y:
        .long   _ZTIN33_GLOBAL__N_t.cc_00000000_E25ADE893fooE

X:
        .long   _ZTIN33_GLOBAL__N_t.cc_00000000_1F13DE273fooE

So the typeinfo are different.


-- 


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


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

* [Bug target/31903] unwanted anonymous namespacing linkage
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
                   ` (3 preceding siblings ...)
  2007-05-11 21:55 ` pinskia at gcc dot gnu dot org
@ 2007-05-11 23:01 ` mrs at apple dot com
  2007-05-12  0:00 ` sabre at nondot dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mrs at apple dot com @ 2007-05-11 23:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mrs at apple dot com  2007-05-12 00:00 -------
Odd, I see:

X:
        .long   _ZTIN12_GLOBAL__N_13fooE
        .weak   _ZTSN12_GLOBAL__N_13fooE
        .section        .gnu.linkonce.r._ZTSN12_GLOBAL__N_13fooE,"a",@progbits
        .type   _ZTSN12_GLOBAL__N_13fooE, @object
        .size   _ZTSN12_GLOBAL__N_13fooE, 21
_ZTSN12_GLOBAL__N_13fooE:
        .string "N12_GLOBAL__N_13fooE"

on my darwin->i386-unknown-linux-gnu compiler?


-- 


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


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

* [Bug target/31903] unwanted anonymous namespacing linkage
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
                   ` (4 preceding siblings ...)
  2007-05-11 23:01 ` mrs at apple dot com
@ 2007-05-12  0:00 ` sabre at nondot dot org
  2007-05-12 13:16 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: sabre at nondot dot org @ 2007-05-12  0:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from sabre at nondot dot org  2007-05-12 01:00 -------
The real bug here is that they are not getting internal linkage.  Just
uniquing/randifying the names would allow them to link, but could be a perf
issue (more symbols for the static/dynamic linker).


-- 


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


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

* [Bug target/31903] unwanted anonymous namespacing linkage
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
                   ` (5 preceding siblings ...)
  2007-05-12  0:00 ` sabre at nondot dot org
@ 2007-05-12 13:16 ` pinskia at gcc dot gnu dot org
  2007-05-12 13:31 ` [Bug c++/31903] [4.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-12 13:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2007-05-12 14:15 -------
(In reply to comment #5)
> on my darwin->i386-unknown-linux-gnu compiler?

It might be because I am using a binutils which has comdat support which is
detected by configure and you did not build a binutils so there is no comdat
support enabled.


-- 


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


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

* [Bug c++/31903] [4.3 Regression] unwanted anonymous namespacing linkage
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
                   ` (6 preceding siblings ...)
  2007-05-12 13:16 ` pinskia at gcc dot gnu dot org
@ 2007-05-12 13:31 ` pinskia at gcc dot gnu dot org
  2007-05-13 22:18 ` geoffk at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-12 13:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2007-05-12 14:30 -------
The name still has to be unque'd for many different reasons.

Anyways this is caused by:
http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00209.html

And if I read the dates correctly, this is only on the trunk and not in 4.2.0:
r118360 | geoffk | 2006-10-31 21:06:12 -0800 (Tue, 31 Oct 2006) | 23 lines

  +-- GCC 4.2 branch created ------+
       |            (Oct 20 2006)  

So I can only assume Geoff applied this to your local 4.2 branch.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |geoffk at gcc dot gnu dot
                   |                            |org
           Severity|normal                      |blocker
             Status|UNCONFIRMED                 |NEW
          Component|target                      |c++
     Ever Confirmed|0                           |1
           Keywords|                            |link-failure, wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2007-05-12 14:30:49
               date|                            |
            Summary|unwanted anonymous          |[4.3 Regression] unwanted
                   |namespacing linkage         |anonymous namespacing
                   |                            |linkage
   Target Milestone|---                         |4.3.0


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


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

* [Bug c++/31903] [4.3 Regression] unwanted anonymous namespacing linkage
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
                   ` (7 preceding siblings ...)
  2007-05-12 13:31 ` [Bug c++/31903] [4.3 Regression] " pinskia at gcc dot gnu dot org
@ 2007-05-13 22:18 ` geoffk at gcc dot gnu dot org
  2007-06-13 22:31 ` [Bug c++/31903] [4.3 Regression] typeinfo of classes in anon namespace isn't being marked static geoffk at gcc dot gnu dot org
  2007-06-14 21:11 ` geoffk at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2007-05-13 22:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from geoffk at gcc dot gnu dot org  2007-05-13 23:18 -------
No DECL whose mangled name includes the name of an anonymous namespace should
be TREE_PUBLIC.  That is the bug here.

There are no problems with typeinfo on systems where typeinfo is compared by
address, which includes Linux and Darwin.  On other systems you'll notice that
the symbols are uniqued.

I don't believe there are any reasons why the names have to be unique on these
systems.  Andrew, if you know some reasons, it would help if you listed them.


-- 


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


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

* [Bug c++/31903] [4.3 Regression] typeinfo of classes in anon namespace isn't being marked static
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
                   ` (8 preceding siblings ...)
  2007-05-13 22:18 ` geoffk at gcc dot gnu dot org
@ 2007-06-13 22:31 ` geoffk at gcc dot gnu dot org
  2007-06-14 21:11 ` geoffk at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2007-06-13 22:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from geoffk at gcc dot gnu dot org  2007-06-13 22:31 -------
I think this problem is limited to just typeinfo.


-- 

geoffk at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |geoffk at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-05-12 14:30:49         |2007-06-13 22:31:14
               date|                            |
            Summary|[4.3 Regression] unwanted   |[4.3 Regression] typeinfo of
                   |anonymous namespacing       |classes in anon namespace
                   |linkage                     |isn't being marked static


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


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

* [Bug c++/31903] [4.3 Regression] typeinfo of classes in anon namespace isn't being marked static
  2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
                   ` (9 preceding siblings ...)
  2007-06-13 22:31 ` [Bug c++/31903] [4.3 Regression] typeinfo of classes in anon namespace isn't being marked static geoffk at gcc dot gnu dot org
@ 2007-06-14 21:11 ` geoffk at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2007-06-14 21:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from geoffk at gcc dot gnu dot org  2007-06-14 21:11 -------
Should be fixed with this change:

------------------------------------------------------------------------
r125721 | geoffk | 2007-06-14 13:56:25 -0700 (Thu, 14 Jun 2007) | 4 lines

        PR 31093
        * decl2.c (determine_visibility): Remove duplicate code for
        handling type info.


-- 

geoffk at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2007-06-14 21:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-11 21:15 [Bug c++/31903] New: unwanted anonymous namespacing linkage mrs at apple dot com
2007-05-11 21:20 ` [Bug target/31903] " pinskia at gcc dot gnu dot org
2007-05-11 21:25 ` pinskia at gcc dot gnu dot org
2007-05-11 21:45 ` mrs at apple dot com
2007-05-11 21:55 ` pinskia at gcc dot gnu dot org
2007-05-11 23:01 ` mrs at apple dot com
2007-05-12  0:00 ` sabre at nondot dot org
2007-05-12 13:16 ` pinskia at gcc dot gnu dot org
2007-05-12 13:31 ` [Bug c++/31903] [4.3 Regression] " pinskia at gcc dot gnu dot org
2007-05-13 22:18 ` geoffk at gcc dot gnu dot org
2007-06-13 22:31 ` [Bug c++/31903] [4.3 Regression] typeinfo of classes in anon namespace isn't being marked static geoffk at gcc dot gnu dot org
2007-06-14 21:11 ` geoffk at gcc dot gnu dot org

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