http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60966
--- Comment #4 from Thomas Sanchez <thomas.sanchz at gmail dot com> --- (In reply to Jonathan Wakely from comment #3) > > > N.B. the std::move in Manager::cancelConnection is redundant, the return > > > value from cancel_connection is already an rvalue. > > > > Yes, I know, the problem is I have some hard time to avoid doing this as it > > is more for me and what I expect the compiler to do or the semantics I want > > the code to have :) > > OK, but it makes the code worse. Here the compiler will elide the move > constructor (aka return value optimisation): > > auto future = cancel_connection(c); > > Whereas here the compiler cannot do that and must call a move constructor: > > auto future = std::move(cancel_connection(c)); I did not meant to say I should continue, far from here :) Thank for the notice! Anyway, I pushed the actual code in this branch: https://github.com/daedric/httpp/tree/bug-promise-test I was able to do a small test that can *sometimes* reproduce the bug: https://github.com/daedric/httpp/blob/bug-promise-test/tests/client/promise.cpp Since I was able to trigger the problem, here are what you asked for: >From the get side, (from here https://github.com/daedric/httpp/blob/bug-promise-test/src/httpp/http/client/Manager.cpp#L113) (gdb) print future $1 = { <std::__basic_future<void>> = { <std::__future_base> = {<No data fields>}, members of std::__basic_future<void>: _M_state = std::shared_ptr (count 2, weak 0) 0x805468 }, <No data fields>} (gdb) print promise $2 = { _M_future = std::shared_ptr (count 2, weak 0) 0x805468, _M_storage = std::unique_ptr<std::__future_base::_Result<void>> containing 0x805780 } (gdb) print &promise $3 = (std::promise<void> *) 0x7fffffffce90 >From the thread calling the pthread_once: #4 0x0000000000500d67 in std::promise<void>::set_value (this=0x7fffffffce90) at /usr/include/c++/4.8/future:1197 1197 _M_future->_M_set_result(std::move(__setter)); (gdb) print *this $4 = { _M_future = std::shared_ptr (count 2, weak 0) 0x805468, _M_storage = std::unique_ptr<std::__future_base::_Result<void>> containing 0x805780 } This is seems to be correct. This has been produced with commit: 850ebba9a72d102b54de6912e820889618a4f30d I'm testing now with the lambdas replaced :) http://reproducible.io/