public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39786]  New: Qualified name lookup through different numbers of using directives
@ 2009-04-16 19:10 hstong at ca dot ibm dot com
  2009-04-17  9:14 ` [Bug c++/39786] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: hstong at ca dot ibm dot com @ 2009-04-16 19:10 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-11-03 22:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-16 19:10 [Bug c++/39786] New: Qualified name lookup through different numbers of using directives hstong at ca dot ibm dot com
2009-04-17  9:14 ` [Bug c++/39786] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
2009-04-22 13:34 ` rguenth at gcc dot gnu dot org
2009-08-04 12:48 ` rguenth at gcc dot gnu dot org
2009-11-03 20:45 ` [Bug c++/39786] [4.3/4.4 " jason at gcc dot gnu dot org
2009-11-03 20:53 ` jason at gcc dot gnu dot org
2009-11-03 21:34 ` jason at gcc dot gnu dot org
2009-11-03 22:09 ` jason at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).