summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.robertl/eb127.C
blob: d8d28b36a6341bde231f6a89f82266636ef9bda1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// { dg-do assemble  }
// Gets ICE 40.

#include <vector>
#include<string>
#include <iostream>

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); // { dg-error "" } should use this->*
}

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);
}