assembly name collisions in C++
Ken Raeburn
raeburn@raeburn.org
Wed Jul 26 10:50:00 GMT 2000
/*
* 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;
}
More information about the Gcc-bugs
mailing list