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

template <typename T>
struct const_ref
{
  const T* begin;
  const_ref(const T* b) : begin(b) {}
};

template <typename T>
T sum(const_ref<T> const& a)
{
  T result = 0;
  for(unsigned i=0;i<1;i++) result += a.begin[i];
  return result;
}

struct tiny_plain
{
  int elems[2];
  tiny_plain() { elems[0]=1; }
};

struct vec3 : tiny_plain {};

struct mat3
{
  int type() const { return sum(const_ref<int>(vec3().elems)) == 1; }
};

int main() { return mat3().type() ? 0 : 1; }