| 1 |
// PR c++/117158 - Similar to eval-order7.C, only with templates. |
| 2 |
// { dg-do run { target c++11 } } |
| 3 |
// { dg-options "-fstrong-eval-order" } |
| 4 |
|
| 5 |
int a[4] = { 1, 2, 3, 4 }; |
| 6 |
int b[4] = { 5, 6, 7, 8 }; |
| 7 |
|
| 8 |
struct Base { |
| 9 |
int *intarray; |
| 10 |
}; |
| 11 |
|
| 12 |
template <typename T> |
| 13 |
struct Sub : public Base { |
| 14 |
int Get(int i) { |
| 15 |
Base::intarray = a; |
| 16 |
int r = Base::intarray[(Base::intarray = b, i)]; |
| 17 |
if (Base::intarray != b) |
| 18 |
__builtin_abort (); |
| 19 |
return r; |
| 20 |
} |
| 21 |
}; |
| 22 |
|
| 23 |
int |
| 24 |
main () |
| 25 |
{ |
| 26 |
Sub<int> s; |
| 27 |
if (s.Get (3) != 4) |
| 28 |
__builtin_abort (); |
| 29 |
} |