summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/compat/init/init-ref2_y.C
blob: 23e66b2f9a140dfebd7b9d334a77bd190ac1fdf9 (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
extern int f (void);
extern int r;

const int *p;

void g ()
{
  static const int &i = f();

  // Test that i points to the same place in both calls.
  if (p && p != &i)
    ++r;
  // Test that if so, it points to static data.
  if (i != 42)
    ++r;

  p = &i;
}

void h ()
{
  int arr[] = { 1, 1, 1, 1, 1, 1, 1 };
  g ();
}