This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Internal compiler error 40: pointer to member function syntax
- To: egcs-bugs at cygnus dot com
- Subject: Internal compiler error 40: pointer to member function syntax
- From: Phil Austin <phil at geog dot ubc dot ca>
- Date: Thu, 8 Jan 1998 10:38:56 -0800
- cc: <gorniau at unixg dot ubc dot ca>, duty at physics dot ubc dot ca
While trying to figure out how to call a pointer to member function
in egcs 1.0 I got the following message:
g++ -g -c test.C
test.C: In method `void ODEsolver::init()':
test.C:41: warning: assuming & on `(*this) .* ODEsolver::midpointODE(vector<double,__default_alloc_template<false,0> > &, double &, double &)'
test.C: In method `void ODEsolver::timeloop(class vector<double,__default_alloc_template<false,0> > &, double, double, double)':
test.C:46: Internal compiler error 40.
test.C:46: Please submit a full bug report to `egcs-bugs@cygnus.com'.
<phil@peacock: test.dir/ODEsolver> g++ -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.90.21/specs
gcc version egcs-2.90.21 971202 (egcs-1.00 release)
<phil@peacock: test.dir/ODEsolver> uname -a
SunOS peacock 5.6 Generic sun4u sparc SUNW,Ultra-2
test.C is appended below. I would also be grateful if someone could
tip me to the correct syntax to invoke a member function via a pointer
to member function. A bare:
useMethod(y,ts,dt);
works in g++ 2.7.2.2 but not with egcs.
Thanks, Phil Austin
-------test.C-------
#include <vector>
#include<string>
using namespace std;
class ODEsolver
{
private:
void eulerODE(vector<double>& y, double& t, double& dt);
void midpointODE(vector<double>& y, double& t, double& dt);
protected:
void (ODEsolver::*useMethod)(vector<double>&, double&, double&);
void init();
public:
ODEsolver();
void timeloop(vector<double>& y, double ts, double te, double dt);
};
ODEsolver::ODEsolver()
{
init();
}
void ODEsolver::eulerODE(vector<double>& y, double& t, double& dt)
{
y[0] = dt * 2.;
}
void ODEsolver::midpointODE(vector<double>& y, double& t, double& dt)
{
y[0] = dt * 3.;
}
void ODEsolver::init()
{
ODEsolver::useMethod = ODEsolver::midpointODE;
}
void ODEsolver::timeloop(vector<double>& y, double ts, double te, double dt)
{
(ODEsolver::useMethod)(y,ts,dt);
}
int main (int nargs, char** args)
{
ODEsolver solver;
vector<double> y(2); double t_start=5.; double t_end=7.; double dt=2.;
solver.timeloop(y,t_start,t_end,dt);
cout << y[0] << endl;
return(0);
}