id summary reporter owner description type status milestone component version severity resolution keywords cc 8674 Futures as local named objects can't be returned with implicit move. mjklaim@… viboes "I could test only with VS 2012 Update 2 so this might be related to a compiler bug, but I can't test the boost code with other compilers/platforms right now. I have this simple test: {{{ #include #define USE_STD 0 #define USE_BOOST 1 #define USED_THREAD_API USE_BOOST #if USED_THREAD_API == USE_BOOST # define BOOST_THREAD_VERSION 4 # include using boost::future; using boost::async; #endif #if USED_THREAD_API == USE_STD # include using std::future; using std::async; #endif future do_something() { auto result = async( []{ std::cout<< ""A\n""; } ); std::cout << ""B\n""; return result; // error here } int main() { do_something().wait(); std::cout << ""Hello, World!"" << std::endl; } }}} Both default Debug and Release modes fail to compile on VS2012 U2: {{{ 1>------ Build started: Project: Test_MoveReturnFuture, Configuration: Debug Win32 ------ 1> main.cpp 1>e:\projects\tests\test_movereturnfuture\test_movereturnfuture\main.cpp(29): error C2248: 'boost::future::future' : cannot access private member declared in class 'boost::future' 1> with 1> [ 1> R=void 1> ] 1> e:\projects\sdk\boost\boost\include\boost-1_53\boost\thread\future.hpp(1406) : see declaration of 'boost::future::future' 1> with 1> [ 1> R=void 1> ] ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== }}} Changing this line: {{{ #define USED_THREAD_API USE_BOOST }}} To this: {{{ #define USED_THREAD_API USE_STD }}} Makes it compile and execute fine. I see that there are move constructors in the definition of future so I don't know at all what's the difference between the two implementations. Another way to avoid the problem is to explicitly move the future: {{{ future do_something() { auto result = async( []{ std::cout<< ""A\n""; } ); std::cout << ""B\n""; return std::move(result); } }}} Which is what I have been doing in my code because I was initially thinking it was a compiler bug, but this Q/A made me reconsider: http://stackoverflow.com/questions/4986673/c11-rvalues-and-move-semantics-confusion I cannot test Boost 1.54 at the moment." Bugs closed Boost 1.54.0 thread Boost 1.53.0 Problem fixed