Bug 15 - template template arguments
Summary: template template arguments
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2000-03-01 14:06 UTC by martin
Modified: 2003-07-25 17:33 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description martin 2000-03-01 14:06:00 UTC
[Original Message-ID: <14525.10553.563957.776958@sokol.math.TU-Berlin.DE>]
Here the wrong specialization is being chosen.


#include <iostream>

template <template <class X> class B, class A>
struct is_instance_of {
   enum { answer=false };
};

template <template <class X> class B, class T>
struct is_instance_of<B, B<T> > {
   enum { answer=true };
};

template <class X> struct C { };
template <class X> struct D { };

template <class T>
bool is_C (const T&) {
   return is_instance_of<C,T>::answer;
};

int main() {
   cout << "should be true: " << is_C(C<int>()) << endl;
   cout << "should be false: " << is_C(D<int>()) << endl;
   return 0;
}


The program prints:

should be true: 1
should be false: 1

Release:
unknown

Environment:
System: Linux mira 2.3.48 #4 Sun Feb 27 23:26:02 CET 2000 i586 unknown
Architecture: i586
Comment 1 Martin v. Loewis 2000-03-08 23:10:45 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed as a bug
Comment 2 Martin v. Loewis 2000-03-09 07:10:45 UTC
From: loewis@gcc.gnu.org
To: gawrilow@math.TU-Berlin.DE, gcc-gnats@gcc.gnu.org,
  martin@loewis.home.cs.tu-berlin.de, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/15
Date: 9 Mar 2000 07:10:45 -0000

 Old Synopsis: [bad code] template template arguments
 New Synopsis: template template arguments
 
 State-Changed-From-To: open->analyzed
 State-Changed-By: loewis
 State-Changed-When: Wed Mar  8 23:10:45 2000
 State-Changed-Why:
     Confirmed as a bug
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=15&database=gcc

Comment 3 Neil Booth 2001-01-11 12:19:05 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed recently in CVS.  I'll add a test case soon.
Comment 4 wanderer 2001-01-11 15:23:28 UTC
From: "Vladimir A. Merzliakov" <wanderer@rsu.ru>
To: <martin@loewis.home.cs.tu-berlin.de>, <gcc-gnats@gcc.gnu.org>,
   <gawrilow@math.TU-Berlin.DE>, <nobody@gcc.gnu.org>
Cc:  
Subject: Re: c++/15
Date: Thu, 11 Jan 2001 15:23:28 +0300

 I check program on gcc version 2.97 20010110 (experimental)
 and after adding 'using namespace std' in main()
 it compile and print
 
 should be true: 1
 should be false: 0
 
 I think bug fixed in CVS version gcc.
 
 Vladimir Merzliakov
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%26pr=15%26database=gcc
 
Comment 5 Neil Booth 2001-01-11 20:19:05 UTC
From: neil@gcc.gnu.org
To: gawrilow@math.TU-Berlin.DE, gcc-gnats@gcc.gnu.org,
  martin@loewis.home.cs.tu-berlin.de, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/15
Date: 11 Jan 2001 20:19:05 -0000

 Synopsis: template template arguments
 
 State-Changed-From-To: analyzed->closed
 State-Changed-By: neil
 State-Changed-When: Thu Jan 11 12:19:05 2001
 State-Changed-Why:
     Fixed recently in CVS.  I'll add a test case soon.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=15&database=gcc