Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/temp-extend3.C

raw
1 // PR c++/119383
2 // { dg-do run { target c++11 } }
3
4 int g;
5
6 struct base {
7 virtual base *clone() const = 0;
8 ~base() { }
9 };
10
11 struct impl : virtual base {
12 base *clone() const { return new impl; } // #1
13 impl() { ++g; }
14 ~impl() { --g; }
15 };
16
17 const base *
18 make_a_clone ()
19 {
20 const base &base = impl{}; // #2
21 return base.clone();
22 }
23
24 int
25 main ()
26 {
27 make_a_clone ();
28 // impl::impl() is called twice (#1 and #2), impl::~impl() once,
29 // at the end of make_a_clone.
30 if (g != 1)
31 __builtin_abort ();
32 }