id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 8596,"With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy",Kees-Jan Dijkzeul ,viboes,"I have build a Treadpool using boost::thread. In porting it to boost 1.53, I've found a regression. Consider attached test-program. It runs correctly on boost 1.49 and earlier. It runs correctly on boost 1.53, with C++0x disabled. With C++0x enabled, it crashes due to an uncaught exception ""call to empty boost::function"" Failure has been observed on Ubuntu Saucy, I.e. boost 1.53, gcc 4.8.0, linux kernel 3.9.0. After some debugging, I believe the problem is caused by packaged_task storing a reference to the boost::function object, instead of a copy. As the boost::function object is a temporary, this leads to undefined behavior further on. I'm guessing this problem is introduced in [81117] By below patch to boost/thread/future.hpp {{{ #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template explicit packaged_task(BOOST_THREAD_RV_REF(F) f , typename disable_if::type, packaged_task>, \ dummy* >::type=0 ) { - typedef typename remove_cv::type>::type FR; + //typedef typename remove_cv::type>::type FR; + typedef F FR; #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK .... }}} Attached: Small application showing the problem For original code please visit https://github.com/kees-jan/scroom/blob/master/inc/scroom/impl/threadpoolimpl.hh#L90",Bugs,closed,Boost 1.54.0,thread,Boost 1.53.0,Problem,fixed,,