public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* g++: conflicting uses of namespace name not reported
@ 2004-02-07 10:15 Ken Raeburn
  2004-02-07 17:25 ` Gabriel Dos Reis
  0 siblings, 1 reply; 2+ messages in thread
From: Ken Raeburn @ 2004-02-07 10:15 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: g++: conflicting uses of namespace name not reported
  2004-02-07 10:15 g++: conflicting uses of namespace name not reported Ken Raeburn
@ 2004-02-07 17:25 ` Gabriel Dos Reis
  0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Dos Reis @ 2004-02-07 17:25 UTC (permalink / raw)
  To: Ken Raeburn; +Cc: gcc-bugs

Ken Raeburn <raeburn@raeburn.org> writes:

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

Funny, you should mention this.  I've just been discussing this
specific example with Giovanni yesterday.  This is a serious defect
in the way we do handle name declarations in g++. I'm taking this over .

[...]

| 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.

And Alex is right.  The code should not have been accepted in the
first place.

-- Gaby


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-02-07 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-07 10:15 g++: conflicting uses of namespace name not reported Ken Raeburn
2004-02-07 17:25 ` Gabriel Dos Reis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).