aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/opt/nrv1.C
blob: cba16252288a240a4992520a63271a7cb6f5bc2a (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
// Test for the named return value optimization.
// { dg-do run }
// { dg-options -fno-inline }

int c;
int d;

struct A
{
  A() { ++c; }
  A(const A&) { ++c; };
  ~A() { ++d; }
};

inline A f ()
{
  A a;
  return a;
}

int main ()
{
  {
    A a = f ();
  }

  return !(c == 1 && c == d);
}