OSDN Git Service

PR c++/37256
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / rv-trivial-bug.C
1 // { dg-do "run" }
2 // { dg-options "-std=c++0x" }
3 // PR c++/33235
4 #include <cassert>
5
6 int move_construct = 0;
7 int move_assign = 0;
8
9 struct base2
10 {
11     base2() {}
12     base2(base2&&) {++move_construct;}
13     base2& operator=(base2&&) {++move_assign; return *this;}
14 };
15
16 int test2()
17 {
18     base2 b;
19     base2 b2(b);
20     assert(move_construct == 0);
21     base2 b3(static_cast<base2&&>(b));
22     assert(move_construct == 1);
23     b = b2;
24     assert(move_assign == 0);
25     b = static_cast<base2&&>(b2);
26     assert(move_assign == 1);
27 }
28
29 int main()
30 {
31     test2();
32     return 0;
33 }