summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/torture/pr44069.C
blob: 99fcd173e27b85d0141e5ddc261433c6bc668585 (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
/* { dg-do run } */

template <unsigned R, unsigned C>
class M {
public:
    M(const int* arr) {
	for (unsigned long r = 0; r < R; ++r)
	  for (unsigned long c = 0; c < C; ++c)
	    m[r*C+c] = arr[r*C+c];
    }
    int operator()(unsigned r, unsigned c) const
      { return m[r*C+c]; }
private:
    int m[R*C];
};
extern "C" void abort (void);
int main()
{
  int vals[2][2] = { { 1, 2 }, { 5, 6 } };
  M<2,2> m( &(vals[0][0]) );
  if (m(1,0) != 5)
    abort ();
  return 0;
}