It appears that qualified name lookup fails to find the correct candidate set for overload resolution in the test case below.
For the following test case, the symptom is rejects-valid; however, it is simple to produce variants for wrong-code and accepts-invalid. The Comeau online compiler compiles the test case successfully. ISO/IEC 14882:2003 Sub-clause 3.4.3.2 [namespace.qual] paragraph 2: === Given X::m (where X is a user-declared namespace), or given ::m (where X is the global namespace), let S be the set of all declarations of m in X and in the transitive closure of all namespaces nominated by using-directives in X and its used namespaces, except that using-directives are ignored in any namespace, including X, directly containing one or more declarations of m. No namespace is searched more than once in the lookup of a name. If S is the empty set, the program is ill-formed. Otherwise, if S has exactly one member, or if the context of the reference is a using-declaration (7.3.3), S is the required set of declarations of m. Otherwise if the use of m is not one that allows a unique declaration to be chosen from S, the program is ill-formed. === We are looking for `f' from the global namespace. The global namespace does not directly contain a declaration of `f'. There are two namespaces nominated by using-directives in the global namespace, ::A and ::B. There are no using-directives in ::A. ::B does not directly contain a declaration of `f'. There is a using- directive in ::B nominating ::B::C. There are no using-directives in ::B::C. S is { ::A::f(char *), ::B::C::f(int) } and overload resolution on the call `::f(0)' should pick ::B::C::f(int). ### Self-contained source (namelookup.C): namespace A { char (*f(char *p))[13] { return 0; } } namespace B { namespace C { char (*f(int p))[42] { return 0; } } using namespace C; } using namespace B; using namespace A; char x[sizeof *::f(0) == 42 ? 1 : -1]; ### Command to reproduce: g++ -c namelookup.C ### Compiler output: namelookup.C:15: error: size of array x is negative ### g++ -v output: Using built-in specs. Target: powerpc64-suse-linux Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.3 --enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --program-suffix=-4.3 --enable-linux-futex --without-system-libunwind --with-cpu=power4 --enable-secureplt --with-long-double-128 --build=powerpc64-suse-linux Thread model: posix gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux) -- Summary: Qualified name lookup through different numbers of using directives Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hstong at ca dot ibm dot com GCC build triplet: powerpc64-suse-linux GCC host triplet: powerpc64-suse-linux GCC target triplet: powerpc64-suse-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39786