summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/nrv9.C
blob: 462506867d439fef6a89256d30fc0593e4484b34 (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
// PR c++/19317
// If we do both NRV and caller-side return slot opt for ga = f()
// constructing la sets ga.i to 0 too soon.

extern "C" void abort();

struct A
{
  int i;
  int pad[32];			// force return in memory
  A(): i(0) {}
  A(int ia): i(ia) {}
};

A ga(42);

A f()
{
  A la;
  if (ga.i != 42)
    abort();
  return la;
}

int main()
{
  ga = f ();
}