summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/other/init2.C
blob: 0b85aa67d0ac03396e7f2109c39f93efd79d0004 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// { dg-do run }

// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 20 Dec 2001 <nathan@nathan@codesourcery.com>

// PR 160. Wrong code emitted for some reference initializers.

void Foo ()
{
}

int fail;

class C
{
  public:
  int m;
  int &r;
  
  C () ;
};

C::C ()
  : m (1), r ((Foo (), m))
{
  m = 10;
  
  if (r != m)
    fail = 1;
  else if (&m != &r)
    fail = 2;
}
int main ()
{
  int m (1);
  int &r ((Foo (),m));

  m = 10;
  if (r != m)
    fail = 3;
  else if (&r != &m)
    fail = 4;

  if (!fail)
    {
      C c;
    }
  return fail;
}