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++/11486] New: Wrong matching of template template parameters for templates with default arguments


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

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

           Summary: Wrong matching of template template parameters for
                    templates with default arguments
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tunali at mojavedesign dot com
                CC: gcc-bugs at gcc dot gnu dot org

The following code :

#include <iostream>
using namespace std;

template <class>
struct A {
  enum { result = 1};
};

template <template<class> class X>
struct A<X<int> > {
  enum {result = 2};
};

template <class>
struct B {};

template <class, class = float>
struct C{};

int main() {
  cout << A<float>::result << endl;
  cout << A<B<int> >::result << endl;
  cout << A<C<int> >::result << endl;
}

generates the following output when compiled and run :

[tunali@localhost temp_temp_param]$ /usr/local/bin/g++ -v default_param.C -Wall 
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs
Configured with: ../gcc-3.2/configure 
Thread model: posix
gcc version 3.2
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/cc1plus -v -D__GNUC__=3
-D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__ELF__
-Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__
-D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1
-D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__
-D__tune_i686__ -D__tune_pentiumpro__ default_param.C -D__GNUG__=3
-D__DEPRECATED -D__EXCEPTIONS -quiet -dumpbase default_param.C -Wall -version -o
/tmp/ccuQ0m6F.s
GNU CPP version 3.2 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2 (i686-pc-linux-gnu)
	compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.3 2.96-112).
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/lib/../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/../include/c++/3.2
 /usr/local/lib/../include/c++/3.2/i686-pc-linux-gnu
 /usr/local/lib/../include/c++/3.2/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/include
 /usr/include
End of search list.
 as -V -Qy -o /tmp/cc3i8LR5.o /tmp/ccuQ0m6F.s
GNU assembler version 2.11.93.0.2 (i386-redhat-linux) using BFD version
2.11.93.0.2 20020207
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/collect2 -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/crtbegin.o
-L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2
-L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../.. /tmp/cc3i8LR5.o -lstdc++
-lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/crtend.o /usr/lib/crtn.o
[tunali@localhost temp_temp_param]$ a.out
1
2
2
[tunali@localhost temp_temp_param]$ 

The output should be 
1
2
1


Both icc and comoeau instantiates the correct class template for A<C<int> >


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