This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

assembly name collisions in C++


/*
 * 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;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]