This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
assembly name collisions in C++
- To: gcc-bugs at gcc dot gnu dot org
- Subject: assembly name collisions in C++
- From: Ken Raeburn <raeburn at raeburn dot org>
- Date: Wed, 26 Jul 2000 13:50:12 -0400 (EDT)
/*
* I don't know the C++ standard well enough to say with authority whether
* namespaces and classes are supposed to have distinct, uh, name spaces,
* but I think it's pretty clear that the compiler should not be indicating
* a successful compilation while generating assembly code that will be
* rejected by the assembler. (Barring use of asm etc.)
*
* If the spaces for namespace and class names are distinct, the name
* encoding needs to be distinct; if they aren't, the compiler should
* detect collisions.
*
* On my x86 Linux box using "GCC: (GNU) 2.96 20000726 (experimental)":
* % /stuff/sourceware/Install/bin/gcc -O9 -save-temps -c foo.cc
* foo.s: Assembler messages:
* foo.s:15: Fatal error: Symbol _3foo.x already defined.
*
* With -fnew-abi I get this instead:
* foo.s:15: Fatal error: Symbol _ZN3foo1xE already defined.
*
* Ken Raeburn
* 2000-Jul-26
*/
class foo {
static int x;
};
int foo::x = 4;
namespace foo {
int x = 3;
}