tree-optimization/115602 - SLP CSE results in cycles
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / unchanging1.C
blob6b2999cb95a2ff316a1b5ada6d8b5ac11c3d2193
1 // { dg-do run  }
2 // { dg-options "-O2" }
4 #include <iostream>
5 #include <complex>
7 using namespace std;
9 class A {
10 protected:
11   int a;
12   complex<double> *b;
13 public:
14   A(int n);
15   inline complex<double>& operator[] (int x);
18 A::A(int n)
20   a = n;
21   b = new complex<double>[a];
22   for (int i=0; i<a; i++) b[i] = complex<double>(0.0,0.0);
25 inline complex<double>& A::operator[](int x)
27   if (x < 0 || x >= a)
28     cout << "x error" << endl;
29   return b[x];
32 void foo ()
34   int n = 5;
35   A *o = new A(n);
36   A *p = new A(n);
37   for (int i = 0; i < n; i++) {
38     cout << i << endl;
39     (*o)[i] *= complex<double>((*p)[i].real(), (*p)[i].imag());
40   }
43 int main()
45   foo();