static member template bug
Ewgenij Gawrilow
gawrilow@math.TU-Berlin.DE
Tue May 12 07:08:00 GMT 1998
The following program:
// ================================================
// stat.cc
#ifndef STATIC
#define STATIC static
#define CONST
#else
#define CONST const
#endif
template <class E>
class a {
private:
E data;
template <class F>
STATIC void sf(const E* e, const F* f) CONST
{ }
public:
a(E d) : data(d) { }
template <class F>
void f(const F* f) const
{
sf(&data,f);
}
};
int main()
{
a<int> a1(1);
double d=2;
a1.f(&d);
}
// ================================================
compiled with:
g++ -Wall -o stat stat.cc
causes an amusing error message:
stat.cc: In method `void a<int>::f(const double *) const':
stat.cc:22: argument passing to `const F *' from `const double *'
whereas a non-static version of it:
g++ -Wall -o stat stat.cc -DSTATIC=
gets compiled without problems.
I use egcs-1.0.2 on an UltraSPARC under Solaris 2.6, configured with default
options (except --prefix, what should not matter):
g++ -v
Reading specs from /usr/local/egcs/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.90.27/specs
gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
With best regards,
Ewgenij Gawrilow,
Dep. of Mathematics,
Technical University Berlin
More information about the Gcc-bugs
mailing list