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)
Confirmed. The code was accepted with 3.3.6
GCC 4.3.4 is being released, adjusting target milestone.
This test now passes with 4.5, presumably because of 2009-10-28 Jason Merrill <jason@redhat.com> Core issue 812, 861 * name-lookup.c (set_decl_namespace): Deal properly with inline namespaces. (qualified_lookup_using_namespace): Overhaul. * pt.c (print_candidates): Handle getting an OVERLOAD. I suppose I could apply the qualified_lookup_using_namespace hunk to 4.3 and 4.4.
Subject: Bug 39786 Author: jason Date: Tue Nov 3 20:52:30 2009 New Revision: 153865 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153865 Log: PR c++/39786 * g++.dg/lookup/using22.C: New. Added: trunk/gcc/testsuite/g++.dg/lookup/using22.C Modified: trunk/gcc/testsuite/ChangeLog
Subject: Bug 39786 Author: jason Date: Tue Nov 3 21:33:55 2009 New Revision: 153872 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153872 Log: PR c++/41876 * parser.c (cp_parser_exception_declaration): Pass true to is_condition parm of cp_parser_type_specifier_seq. (cp_parser_omp_for_loop): Likewise. PR c++/39786, Core issue 812, 861 * name-lookup.c (qualified_lookup_using_namespace): Overhaul. Added: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/inline-ns3.C - copied unchanged from r153682, trunk/gcc/testsuite/g++.dg/cpp0x/inline-ns3.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/using22.C - copied unchanged from r153865, trunk/gcc/testsuite/g++.dg/lookup/using22.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/parse/eh-decl.C - copied unchanged from r153864, trunk/gcc/testsuite/g++.dg/parse/eh-decl.C Modified: branches/gcc-4_4-branch/gcc/cp/ChangeLog branches/gcc-4_4-branch/gcc/cp/name-lookup.c branches/gcc-4_4-branch/gcc/cp/parser.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/using16.C
Fixed fer 4.4.3, 4.5.0. I'm not comfortable applying the fix to 4.3 as it might have unintended side-effects.