
Surprisingly (well not really), the following example doesn't fails at *1*. This is because the coroutine have access to its coroutine parameters *2*, which has a sens only for the first time the coroutine is called.
your exchange addresses between main() and coroutine-fn (lifetime()). you could use it also a second time etc. as long as the object does not go out of scope.
Once the first call to yield return, the memory these parameter *3* can point to trash, as the example shows.
sorry - that is not an issue of boost.coroutine itself. Who would store pointers/references to objects and expects that those objects can still be accessed over the pointers/references after those objects were destroyed. But that is the case in your example. Your example in issue *3* is equivalent to storing an reference as member in some class and access the member after the original object was gone out of scope. struct X { void g() {} }; struct Y { X & x; Y( X & x_) : x( x_) {} void f() { x.g(); } }; Y u() { X x; Y y( x); y.f(); // OK } void main() { Y y( u() ); y.f(); // segfault } Oliver