g++: conflicting uses of namespace name not reported
Ken Raeburn
raeburn@raeburn.org
Sat Feb 7 10:15:00 GMT 2004
I reported this before in
http://gcc.gnu.org/ml/gcc-bugs/2000-07/msg00683.html against 2.96, but
it appears not to be in the bugzilla database, and still appears to be
broken in "GCC: (GNU) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)" and
"GCC: (GNU) 3.3.2 (NetBSD nb1 20031026)" according to the .ident
strings output on a couple of systems. I'm checking out a fresh copy
from the GCC CVS repository, but it's taking a long time...
Defining a class and a namespace by the same name is not flagged as
an error by the C++ compiler, even though variables by the same names
can be created in each, and will cause an assembly-time error.
class X { static int x; };
int X::x = 42;
namespace X { int x = 3; };
On my NetBSD box, both "x" variables have assembly labels of
"_ZN1X1xE", causing the assembler to reject the file with a message
of fairly little use to the programmer:
% gcc -O9 -c namespace.cc
/var/tmp//ccIa4W3z.s: Assembler messages:
/var/tmp//ccIa4W3z.s:13: Error: symbol `_ZN1X1xE' is already defined
If you check the followups to my original report, Alex Samuel
indicated that the error appears to be in the compiler accepting this
file, not in failing to generate distinct names.
Ken
More information about the Gcc-bugs
mailing list