gcc/testsuite/g++.dg/compat/init/init-ref2_y.C
raw| 1 | extern int f (void); |
| 2 | extern int r; |
| 3 | |
| 4 | const int *p; |
| 5 | |
| 6 | void g () |
| 7 | { |
| 8 | static const int &i = f(); |
| 9 | |
| 10 | // Test that i points to the same place in both calls. |
| 11 | if (p && p != &i) |
| 12 | ++r; |
| 13 | // Test that if so, it points to static data. |
| 14 | if (i != 42) |
| 15 | ++r; |
| 16 | |
| 17 | p = &i; |
| 18 | } |
| 19 | |
| 20 | void h () |
| 21 | { |
| 22 | int arr[] = { 1, 1, 1, 1, 1, 1, 1 }; |
| 23 | g (); |
| 24 | } |