g++ (GCC) 4.0.3 20051111 (prerelease) (Debian 4.0.2-4) g++ fails to compile the attached program with the following error $ g++ bug.cpp bug.cpp: In member function 'void B::foo(N::C)': bug.cpp:12: error: cannot convert 'N::C' to 'long int' for argument '1' to 'void foo(long int)' Note that removing namespace enclosure make the program compile fine.
Created attachment 10318 [details] Testcase (bug.cpp)
I don't think this is a bug as what is happening is that :: is a qualified name and qualified namelookup (IIRC) does not find decls which are injected via using.
(In reply to comment #2) > I don't think this is a bug as what is happening is that :: is a qualified name > and qualified namelookup (IIRC) does not find decls which are injected via > using. > It does find. The following program (where `foo(long)` is commented out) is compiled fine. === namespace N { class C {}; void foo(C) {}; } using namespace N; /* void foo(long) {}; */ class B { public: /* void foo(long l) { ::foo(l); }; */ void foo(C c) { ::foo(c); }; }; int main() { B b; return 0; } ===
I don't have chapter and verse to justify this, but icc and gcc agree that they should reject this code -------------- namespace N { class C {}; void foo(C) {}; } using namespace N; void foo(long) {}; void bar() { C c; ::foo(c); }; --------------------- while they both accept the code with ::foo(long) removed: --------------------- namespace N { class C {}; void foo(C) {}; } using namespace N; void bar() { C c; ::foo(c); }; --------------------- One may certainly be tempted to find this confusing. W.
Closing.