This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Namespace Issue
- From: "Stephan T. Lavavej" <stl at caltech dot edu>
- To: "GCC" <gcc at gcc dot gnu dot org>
- Date: Fri, 14 May 2004 19:00:35 -0700
- Subject: Namespace Issue
- Reply-to: <stl at caltech dot edu>
Consider the following C++ snippet:
namespace meow {
struct mlar { };
}
namespace oink {
using namespace meow;
void fxn(mlar s);
}
void oink::fxn(/* LOOK HERE */ mlar s) { }
Note that namespace qualification is omitted on the parameter type in the
definition: mlar s instead of meow::mlar s.
gcc 3.3.3 and the online Comeau compiler (and, I am told, gcc 3.4.0) accept
this code without complaint; MSVC 7.1 rejects it. I believe that gcc is
correct to accept it, but I don't know if the code is legal, so this may be
a gcc bug.
I've looked through the Standard (haven't found anything that addresses this
issue) and asked on comp.lang.c++.moderated (no useful replies yet). The
Standard should also explain why gcc (correctly, I think) rejects omitted
qualification on return types in definitions.
So, I'm asking here, because presumably someone programmed this behavior
into gcc and should be able to answer. Is the code legal?
Stephan T. Lavavej
http://nuwen.net