OSDN Git Service

2009-07-17 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / torture / pr30567.C
1 /* { dg-do run } */
2
3 template <typename T>
4 struct const_ref
5 {
6   const T* begin;
7   const_ref(const T* b) : begin(b) {}
8 };
9
10 template <typename T>
11 T sum(const_ref<T> const& a)
12 {
13   T result = 0;
14   for(unsigned i=0;i<1;i++) result += a.begin[i];
15   return result;
16 }
17
18 struct tiny_plain
19 {
20   int elems[2];
21   tiny_plain() { elems[0]=1; }
22 };
23
24 struct vec3 : tiny_plain {};
25
26 struct mat3
27 {
28   int type() const { return sum(const_ref<int>(vec3().elems)) == 1; }
29 };
30
31 int main() { return mat3().type() ? 0 : 1; }
32