Debian Codegraph @

gcc/testsuite/g++.dg/opt/pr103842.C

raw
1 // PR target/103842
2 // { dg-do compile }
3 // { dg-options "-O3 -std=c++14" }
4
5 void foo (float *);
6 struct M {
7 float x[3][3];
8 float *operator[](int i) { return x[i]; }
9 M();
10 M(float f, float g) {
11 x[1][0] = x[1][1] = x[1][2] = f;
12 x[2][0] = g;
13 }
14 void bar();
15 M baz() {
16 M s(x[1][2] - x[1][2], x[1][1] - x[1][1]);
17 float r = s[2][0];
18 if (r)
19 for (int i = 0; i < 3; ++i)
20 for (int j = 0; j < 3; ++j)
21 s[i][j] /= r;
22 for (int i = 0;;) {
23 float *t = s[i];
24 foo(t);
25 }
26 }
27 };
28 void qux() {
29 M m, i = m.baz(), j = i;
30 j.bar();
31 }