gcc/testsuite/g++.dg/cpp0x/rvo.C
raw| 1 | // { dg-do run { target c++11 } } |
| 2 | // Contributed by Sylvain Pion |
| 3 | static int rvalue_constructions = 0; |
| 4 | |
| 5 | struct A { |
| 6 | A () { } |
| 7 | A (const A&) { } |
| 8 | A (A&&) { ++rvalue_constructions; } |
| 9 | ~A () { } |
| 10 | }; |
| 11 | |
| 12 | A f() { return A(); } |
| 13 | |
| 14 | extern "C" { |
| 15 | void abort(void); |
| 16 | } |
| 17 | |
| 18 | int main() |
| 19 | { |
| 20 | A c = f(); |
| 21 | |
| 22 | if (rvalue_constructions != 0) |
| 23 | abort(); |
| 24 | } |