2 // { dg-options "-O2" }
3 // We used to mis-compile this testcase as we did not know that
4 // &a+offsetof(b,a) was the same as &a.b
9 Iterator(int * i) : ptr(i) { }
10 void operator++() { ++ptr; }
11 int *const & base() const { return ptr; }
15 Iterator find_7(Iterator first, Iterator last)
17 int trip_count = (last.base() - first.base()) >> 1;
19 for ( ; trip_count > 0 ; --trip_count) {
20 if (*first.ptr == 7) return first;
23 if (*first.ptr == 7) return first;
27 switch(last.base() - first.base()) {
29 if (*first.ptr == 7) return first;
38 int as[5] = {4,4,4,4,7};
39 return (find_7(Iterator(&as[0]), Iterator(&as[5])).ptr == &as[5]);