This is the mail archive of the gcc@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]
Other format: [Raw text]

Namespace Issue


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




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