This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Patch for template bug
- To: egcs-bugs at cygnus dot com, Jason Merrill <jason at cygnus dot com>
- Subject: Patch for template bug
- From: Mark Mitchell <mmitchell at usa dot net>
- Date: Wed, 26 Nov 1997 12:08:50 -0800
- Reply-to: mmitchell at usa dot net
Here's a bug report and (easy) fix.
template <class S, class T>
class mem_fun1_t {
public:
mem_fun1_t(S (T::*pf)(double)) {}
};
template <class T>
class mem_fun1_t<void, T> {
public:
mem_fun1_t(void (T::*pf)(double)) {}
};
struct Operation {
double eval(double) {}
};
int main() {
mem_fun1_t<double, Operation> m(&Operation::eval);
}
supernova% g++ -c test.cpp
test.cpp:20: sorry, not implemented: use of `void_type' in template type unification
I believe that this fix should go on the release branch: it's very low
risk, and came up for me when using STL.
--
Mark Mitchell mmitchell@usa.net
Stanford University http://www.stanford.edu
1997-11-26 Mark Mitchell <mmitchell@usa.net>
* pt.c (unify): Handle `void' template parameters in
specializations.
Index: gcc/cp/pt.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/cp/pt.c,v
retrieving revision 1.1.1.3
diff -c -p -r1.1.1.3 pt.c
*** pt.c 1997/11/25 00:49:42 1.1.1.3
--- pt.c 1997/11/26 19:57:02
*************** unify (tparms, targs, ntparms, parm, arg
*** 3851,3856 ****
--- 3851,3857 ----
case COMPLEX_TYPE:
case INTEGER_TYPE:
case BOOLEAN_TYPE:
+ case VOID_TYPE:
if (TREE_CODE (arg) != TREE_CODE (parm))
return 1;
Index: gcc/testsuite/g++.old-deja/g++.pt/spec1.C
===================================================================
RCS file: spec1.C
diff -N spec1.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- spec1.C Wed Nov 26 12:00:39 1997
***************
*** 0 ****
--- 1,21 ----
+ // Build don't link:
+
+ template <class S, class T>
+ class mem_fun1_t {
+ public:
+ mem_fun1_t(S (T::*pf)(double)) {}
+ };
+
+ template <class T>
+ class mem_fun1_t<void, T> {
+ public:
+ mem_fun1_t(void (T::*pf)(double)) {}
+ };
+
+ struct Operation {
+ double eval(double) {}
+ };
+
+ int main() {
+ mem_fun1_t<double, Operation> m(&Operation::eval);
+ }