summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/initlist-nrv1.C
blob: e44dbecfece4ffbbf8552c65d3669ed62fba0dac (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
// PR c++/101442
// { dg-do run { target c++11 } }

bool destroyed = false;

struct A
{
  A() {}
  A(const A &) = delete;
  A &operator=(const A &) = delete;
  ~A() {destroyed = true;}
};

struct B
{
  const A &a;
  struct string {
    string(const char*) { }
    ~string() { }
  } s;
};

B foo()
{
  B ret{ A{}, "" };
  return ret;
}

int main()
{
  B b = foo();
  if (!destroyed)
    __builtin_abort();
}