This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/29971] New: anonymous namespace vs deprecated static keyword (different linkage).
- From: "pluto at agmk dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Nov 2006 13:43:32 -0000
- Subject: [Bug other/29971] New: anonymous namespace vs deprecated static keyword (different linkage).
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
in theory the anonymous namespace is a `static' keyword superior.
in fact it breaks applications that use dlopen() with RTLD_GLOBAL.
the so called superior emits symbols with different binding.
e.g.:
static keyword:
00000000 4 OBJECT LOCAL DEFAULT 4 N::a_
namespace superior:
00000000 4 OBJECT GLOBAL DEFAULT 4 N::(anonymous namespace)::a_
$ make CPPFLAGS=-DSUPERIOR && ./main
i486-gnu-linux-g++ -Wall -O1 -g0 -s -DSUPERIOR *.cpp -c
i486-gnu-linux-g++ -Wall -O1 -g0 -s -DSUPERIOR m1.o A.o -o libm1.so -shared
i486-gnu-linux-g++ -Wall -O1 -g0 -s -DSUPERIOR m2.o A.o -o libm2.so -shared
i486-gnu-linux-g++ -Wall -O1 -g0 -s -DSUPERIOR main.cpp -o main -ldl
i486-gnu-linux-strip --strip-unneeded *.so main
i1 = 0x55b6b4
i2 = 0x55b6b4
Aborted
$ make && ./main
i486-gnu-linux-g++ -Wall -O1 -g0 -s *.cpp -c
i486-gnu-linux-g++ -Wall -O1 -g0 -s m1.o A.o -o libm1.so -shared
i486-gnu-linux-g++ -Wall -O1 -g0 -s m2.o A.o -o libm2.so -shared
i486-gnu-linux-g++ -Wall -O1 -g0 -s main.cpp -o main -ldl
i486-gnu-linux-strip --strip-unneeded *.so main
i1 = 0x759670
i2 = 0x112670
--
Summary: anonymous namespace vs deprecated static keyword
(different linkage).
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pluto at agmk dot net
GCC target triplet: elf-*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29971