[Bug c++/35383] New: Lookup of template dependent function with overloads fails for namespace-qualified parameter

dpfurlani at raytheon dot com gcc-bugzilla@gcc.gnu.org
Tue Feb 26 18:49:00 GMT 2008


Can someone confirm if this is the same non-bug reported in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29844 or if it is a regression? 
The code compiles in gcc 3.4.4 and 4.0.2 but not in 4.1.2, and I don't
understand why.  Especially since func2() doesn't have the same problem that
func() does.

template<typename T>
struct Holder
{
   T item;
};

template<typename T>
void func(Holder<T> hold)
{
   hold.item.a = 2;  // OK
   func(hold.item);  // OK for Wilma, but fails for Foo::Fred, see below
   func2(hold.item); // OK, not overloaded name
}

namespace Foo {
   struct Fred { int a; };
}

struct Wilma { int a; };

void func(Foo::Fred f); // move this line inside namespace Foo, and all is OK
void func(Wilma w);

void func2(Foo::Fred f);
void func2(Wilma w);

int main()
{
  Holder<Foo::Fred> fred;
  func(fred);

  Holder<Wilma> wilma;
  func(wilma);

  return 0;
}

/*****************************************************************************
$ g++ -v
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure
--verbose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls
--without-included-gettext --enable-version-specific-runtime-libs --without-x
--enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter
--disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm
--disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization
--enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)

$ g++ -c -W -Wall gcc-dependent-name-lookup.cpp

******************************************************************************
$ g++ -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--host=i386-redhat-linux
Thread model: posix
gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)

$ g++ -c -W -Wall gcc-dependent-name-lookup.cpp

******************************************************************************
C:\>ccppc -v
Using built-in specs.
Target: powerpc-wrs-vxworks
Configured with: /scratch/nathan/vxworks/src/gcc-4.1/configure
--build=i686-pc-linux-gnu --host=i686-mingw32 --target=powerpc-wrs-vxworks
--enable-threads --disable-libmudflap --disable-libssp --disable-libgomp
--disable-libstdcxx-pch --enable-sjlj-exceptions --disable-hosted-libstdcxx
--enable-version-specific-runtime-libs --with-gnu-as --with-gnu-ld
--enable-languages=c,c++ --disable-shared --disable-hosted-libstdcxx
--with-cxxabi=/scratch/nathan/vxworks/src/dinkum-20021215/include
--with-pkgversion='Wind River VxWorks G++ 4.1-82'
--with-bugurl=support@windriver.com --disable-nls --prefix=/opt/codesourcery
--exec-prefix='/x86-win32' --libdir='/lib'
--program-transform-name='s,^gcc$,cc,;s,$,ppc,'
--with-libiconv-prefix=/scratch/nathan/vxworks/powerpc/obj/host-libs-4.1-82-powerpc-wrs-vxworks-i686-mingw32/usr
--with-gxx-include-dir=''\''/'\''include/c++/4.1'
--with-license=/scratch/nathan/vxworks/powerpc/obj/host-libs-4.1-82-powerpc-wrs-vxworks-i686-mingw32/usr
--with-csl-license-version=20071015
--with-csl-license-feature=gcc_Power_VxWorks --enable-poison-system-directories
Thread model: vxworks
gcc version 4.1.2 (Wind River VxWorks G++ 4.1-82)

C:\>ccppc -c -W -Wall gcc-dependent-name-lookup.cpp
gcc-dependent-name-lookup.cpp: In function 'void func(Holder<T>) [with T =
Foo::Fred]':
gcc-dependent-name-lookup.cpp:30:   instantiated from here
gcc-dependent-name-lookup.cpp:11: error: no matching function for call to
'func(Foo::Fred&)'

*****************************************************************************/


-- 
           Summary: Lookup of template dependent function with overloads
                    fails for namespace-qualified parameter
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dpfurlani at raytheon dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35383



More information about the Gcc-bugs mailing list