c++/3671: g++ incorrectly tries to instantiate multiple member template specializations

Wolfgang Bangerth bangerth@ticam.utexas.edu
Thu Nov 21 21:06:00 GMT 2002


The following reply was made to PR c++/3671; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-gnats@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>
Cc:  
Subject: Re: c++/3671: g++ incorrectly tries to instantiate multiple member
 template specializations
Date: Fri, 15 Nov 2002 20:25:42 -0600 (CST)

 Good question what happens here:
 ----------------------------------
 enum T1 {a};
 enum T2 {b};
 
 struct Y {
   template <T1 i> void foo();
   template <T2 i> void foo();
 };
 
 template void Y::foo<a> ();
 
 // int main() {
 //   Y c;
 //   c.foo<a>();
 // }
 ---------------------------------
 I get
 tmp/g> /home/bangerth/bin/gcc-3.3x-pre/bin/c++ x.cc
 x.cc:9: error: cannot convert `T1' to `T2' in initialization
 x.cc:9: error: non-constant `<expression error>' cannot be used as template
    argument
 x.cc: In instantiation of `void Y::foo() [with T1 i = a]':
 x.cc:9:   instantiated from here
 x.cc:9: error: explicit instantiation of `void Y::foo() [with T1 i = a]' 
 but no
    definition available
 
 
 If I use the commented main function instead of the explicit 
 instantiation, I get
 tmp/g> /home/bangerth/bin/gcc-3.3x-pre/bin/c++ x.cc
 x.cc: In function `int main()':
 x.cc:13: error: cannot convert `T1' to `T2' in initialization
 x.cc:13: error: non-constant `<expression error>' cannot be used as template
    argument
 
 which I find even less helpful.
 
 Regards
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 



More information about the Gcc-prs mailing list