summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/rvo.C
blob: d4459af64d3927035f84e506a05780226aedebaf (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
// { dg-do run }
// { dg-options "-std=c++0x" }
// Contributed by Sylvain Pion
static int rvalue_constructions = 0;

struct A {
  A ()         { }
  A (const A&) { }
  A (A&&)      { ++rvalue_constructions; }
  ~A ()        { }
};

A f() {  return A(); }

extern "C" {
  void abort(void);
}

int main()
{
  A c = f();

  if (rvalue_constructions != 0)
    abort();
}