| 1 | | boost::coroutines::coroutine<X*>::push_type is not possible with the new version |
| 2 | | (boost::coroutines::coroutine<X*()> is deprecated) |
| | 1 | add |
| | 2 | X() { |
| | 3 | std::cout << "X()" << std::endl; |
| | 4 | } |
| | 5 | |
| | 6 | ~X() { |
| | 7 | std::cout << "~X()" << std::endl; |
| | 8 | } |
| | 9 | |
| | 10 | void g() { |
| | 11 | std::cout << "X::g()" << std::endl; |
| | 12 | } |
| | 13 | |
| | 14 | |
| | 15 | and the output will be: |
| | 16 | |
| | 17 | X() |
| | 18 | ~X() |
| | 19 | X::g() |
| | 20 | |
| | 21 | the stack gets unwound but the objects (bit structure) is still available. |
| | 22 | |
| | 23 | change X to: |
| | 24 | |
| | 25 | struct X { |
| | 26 | |
| | 27 | int x; |
| | 28 | X() : x( 1) { |
| | 29 | std::cout << "X(): " << x << std::endl; |
| | 30 | } |
| | 31 | |
| | 32 | ~X() { |
| | 33 | x = 7; |
| | 34 | std::cout << "~X(): " << x << std::endl; |
| | 35 | } |
| | 36 | |
| | 37 | void g() { |
| | 38 | std::cout << "X::g(): " << x << std::endl; |
| | 39 | } |
| | 40 | |
| | 41 | }; |
| | 42 | |
| | 43 | and you will get your segmentation fault (gcc + clang) |