summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/nrv2.C
blob: 4ffc075878d3671de5c2672a88517093c62f9053 (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, this time with inlining.
// { dg-do run }
// { dg-options -O2 }

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);
}