This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11154] New: g++-3.3 reports ambiguous class template instantiation for non-ambiguous specialization


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: g++-3.3 reports ambiguous class template instantiation
                    for non-ambiguous specialization
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: lorgon1@yahoo.com
                CC: gcc-bugs@gcc.gnu.org

g++-3.3 reports an error (ambiguous template instantiation) for a non-ambiguous case. 
I have reduced it to a very tiny test program.

Preprocessed source file which exposes the bug:

pitcairn:/net/hc282/lorgon/FC++/FC++-clients> cat tmp.ii
# 1 "tmp.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "tmp.cc"

template <class A> struct Outer {
   template <class T, class U = void, class V = void> struct Foo {};
   template <class T, class U> struct Foo<T,U,void> {};
   template <class T> struct Foo<T,void,void> {};
};

Outer<int>::Foo<int,void,void> f;

int main() {
}
pitcairn:/net/hc282/lorgon/FC++/FC++-clients> 

Here is what g++-3.3 has to say:

pitcairn:/net/hc282/lorgon/FC++/FC++-clients> g++-3.3 -Wall tmp.cc
tmp.cc:8: error: ambiguous class template instantiation for `struct 
   Outer<int>::Foo<int, void, void>'
tmp.cc:5: error: candidates are: struct Outer<A>::Foo<T, void, void>
tmp.cc:4: error:                 struct Outer<A>::Foo<T, U, void>
tmp.cc:8: error: aggregate `Outer<int>::Foo<int, void, void> f' has incomplete 
   type and cannot be defined
tmp.cc:8: error: storage size of `f' isn't known
pitcairn:/net/hc282/lorgon/FC++/FC++-clients> 

The output is wrong; there should be no error.  Prior versions of gcc and other compilers 
get it right.

Here is the platform/etc info:


Script started on Wed Jun 11 11:36:36 2003
pitcairn:/net/hc282/lorgon/FC++/FC++-clients> g++-3.3 -v -save-temps -Wall tmp.cc
Reading specs from /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/lib/gcc-lib/sparc-
sun-solaris2.8/3.3/specs
Configured with: /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3/configure --prefix=/net/
hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run --program-suffix=-3.3 --enable-threads --
enable-languages=c++
Thread model: posix
gcc version 3.3
 /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/lib/gcc-lib/sparc-sun-solaris2.8/3.3/
cc1plus -E -D__GNUG__=3 -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -
D__GNUC_PATCHLEVEL__=0 -Dsparc -D__sparc__ -D__sparc -
D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc tmp.cc -Wall tmp.ii
ignoring nonexistent directory "/net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/sparc-
sun-solaris2.8/include"
#include "..." search starts here:
#include <...> search starts here:
 /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/include/c++/3.3
 /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/include/c++/3.3/sparc-sun-solaris2.8
 /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/include/c++/3.3/backward
 /usr/local/include
 /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/include
 /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/lib/gcc-lib/sparc-sun-solaris2.8/3.3/
include
 /usr/include
End of search list.
 /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/lib/gcc-lib/sparc-sun-solaris2.8/3.3/
cc1plus -fpreprocessed tmp.ii -quiet -dumpbase tmp.cc -auxbase tmp -Wall -version -o 
tmp.s
GNU C++ version 3.3 (sparc-sun-solaris2.8)
        compiled by GNU C version 3.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
tmp.cc:8: error: ambiguous class template instantiation for `struct 
   Outer<int>::Foo<int, void, void>'
tmp.cc:5: error: candidates are: struct Outer<A>::Foo<T, void, void>
tmp.cc:4: error:                 struct Outer<A>::Foo<T, U, void>
tmp.cc:8: error: aggregate `Outer<int>::Foo<int, void, void> f' has incomplete 
   type and cannot be defined
tmp.cc:8: error: storage size of `f' isn't known
pitcairn:/net/hc282/lorgon/FC++/FC++-clients> exit

script done on Wed Jun 11 11:37:20 2003


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]