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]

Spezialization and friends


Hi,

why does defining BUG ind the following code
/* bug_fullspec.cc */
/* egcs (980315) bug */
/* 98/03/16 Kurt Garloff <K.Garloff@ping.de> */

#include <stdio.h>


template <unsigned rank> class Tensor;
#ifdef BUG
template <unsigned rank>
Tensor<rank> func (double&);
#endif

template <unsigned rank>
class Tensor
{
 public:
	int dim[rank];
	double *data;
	
 public:
	Tensor (const int d = 0)
	{       
		int ne = 1; 
		for (int i = 0; i < d; i++)
		{ ne *= d; dim[i] = d; };
		data = new double[ne];
	};
	Tensor (const int, const int);
#ifdef BUG
	friend Tensor<rank> func <> (double&);
#endif
};

#ifdef BUG
template <unsigned rank>
Tensor<rank> func (double& d)
{ return Tensor<rank> (1); };
#endif

template <>
Tensor<2>::Tensor (const int d0, const int d1)
{
	dim[0] = d0; dim[1] = d1;
	data = new double[d0*d1];
};

int main ()
{
	Tensor<4> t4 (3);
	Tensor<2> t2 (2, 3);
	
	printf ("%i %i\n", t4.dim[0], t2.dim[0]);
};

lead to this error:

garloff@kg1:/home/garloff/C > egcc -O2 bug_fullspec.cc -DBUG
bug_fullspec.cc:42: incomplete type unification
bug_fullspec.cc:42: func<>' does not match any template declaration
bug_fullspec.cc:42: confused by earlier errors, bailing out

but does compile without the friend function ?

Shouldn't the behaviour independent of it? (And in my opinion succeed in
both cases?)

-- 
Kurt Garloff, Dortmund 
<K.Garloff@ping.de>
PGP key on http://student.physik.uni-dortmund.de/homepages/garloff


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