-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix callcc functionality for g++-4.9 #55
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this patch on x86_64 Linux with g++-4.9, g++-5.4, and g++-6.2. All tests passed for all tested compiler toolchains.
@@ -451,7 +452,8 @@ class continuation { | |||
template< | |||
typename Fn, | |||
typename ... Arg, | |||
typename = detail::disable_overload< continuation, Fn > | |||
typename = detail::disable_overload< continuation, Fn >, | |||
typename = detail::disable_overload< std::allocator_arg_t, Fn > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extra disable_overload
fixes the compiler error for me.
@@ -354,15 +355,15 @@ class continuation { | |||
template< typename Fn, typename ... Arg > | |||
continuation resume_with( Fn && fn, Arg ... arg) { | |||
BOOST_ASSERT( nullptr != t_.fctx); | |||
auto tpl = std::make_tuple( std::forward< Fn >( fn), std::forward< Arg >( arg) ... ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the type of tpl
here is std::tuple<Fn, Arg...>
.
detail::transfer_t context_ontop( detail::transfer_t t) { | ||
auto p = static_cast< std::tuple< Fn, std::tuple< Arg ... > > * >( t.data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the expected type for t.data
is std::tuple< Fn, std::tuple< Arg ... > > *
, which does not correspond to the argument type declared on line 357 below.
My guess is that the C++ library implementation for std::tuple
changed between g++-4.9 and g++-5, which is why this bad cast happened to work with newer g++ versions but fails with version 4.9.
hmm, did noticed that mistake - strage that I got fooled by so much compilers (clang, msvc, intel compile this code). |
Fix callcc functionality for g++-4.9
Fixes the resolution issue discussed in #52 and #54 that caused compiler errors when using g++-4.9. Also fixes a bad cast that was causing bad values to be passed as arguments into continuations.