Skip to content
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

Merged
merged 1 commit into from
Apr 22, 2017

Conversation

DaoWen
Copy link
Contributor

@DaoWen DaoWen commented Apr 20, 2017

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.

Copy link
Contributor Author

@DaoWen DaoWen left a 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 >
Copy link
Contributor Author

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) ... );
Copy link
Contributor Author

@DaoWen DaoWen Apr 20, 2017

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);
Copy link
Contributor Author

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.

@olk
Copy link
Member

olk commented Apr 22, 2017

hmm, did noticed that mistake - strage that I got fooled by so much compilers (clang, msvc, intel compile this code).
ty for fixing it.

@olk olk merged commit a673b2a into boostorg:develop Apr 22, 2017
olk added a commit that referenced this pull request Apr 22, 2017
Fix callcc functionality for g++-4.9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants