Opened 9 years ago
Closed 9 years ago
#9035 closed Bugs (invalid)
Coroutine test code should produce segmentation fault, but actually not.
Reported by: | anonymous | Owned by: | olli |
---|---|---|---|
Milestone: | To Be Determined | Component: | coroutine |
Version: | Boost 1.54.0 | Severity: | Problem |
Keywords: | Cc: |
Description
According to Boost Coroutine documentation, the following piece of code shall produce segmentation fault, since "c"'s stack gets unwound and "x" should remain to be a nullptr, however "x" becomes non-null after the scoped coroutine code.
I am not sure (since I am very new to Boost Coroutine lib) whether it is because of my mistake.
My Boost 1.54 was compiled using Clang 3.3. I tested the code both using Clang 3.4 trunk and GCC 4.6.4.
Thanks.
===================================
#include <boost/coroutine/all.hpp>
struct X {
void g() {}
};
typedef boost::coroutines::coroutine<X*()> coro_t;
void fn(coro_t::caller_type& ca) {
X local; ca(&local);
}
int main() {
X* x = 0; {
coro_t c(fn); x = c.get();
}
x->g(); return 0;
}
add
and the output will be:
X() ~X() X::g()
the stack gets unwound but the objects (bit structure) is still available.
change X to:
struct X {
};
and you will get your segmentation fault (gcc + clang)