------- Comment #8 from redi at gcc dot gnu dot org 2010-01-03 17:57 ------- Created an attachment (id=19453) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19453&action=view) preliminary patch
I'm testing this, which is not ready for checkin, but updates std::bind to handle rvalues and fixes this bug. As well as fixing the affected testcases (done but not included in this patch) and fixing the formatting, the decaying behaviour from the resolution to LWG 817 needs to be implemented: http://home.roadrunner.com/~hinnant/issue_review/lwg-active.html#817 I *think* the patch is correct, but testsuite/30_threads/call_once/39909.cc fails due to a front-end bug: /home/redi/src/gcc/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/functional:1179:67: sorry, unimplemented: unable to determine the declared type of expression 'declval<std::reference_wrapper<Inc> >()()' A workaround for this is to change call_once to use bind<void>() instead of bind() i.e. Index: include/std/mutex =================================================================== --- include/std/mutex (revision 155587) +++ include/std/mutex (working copy) @@ -722,12 +722,12 @@ namespace std call_once(once_flag& __once, _Callable __f, _Args&&... __args) { #ifdef _GLIBCXX_HAVE_TLS - auto __bound_functor = std::bind(__f, __args...); + auto __bound_functor = std::bind<void>(__f, __args...), __once_callable = &__bound_functor; __once_call = &__once_call_impl<decltype(__bound_functor)>; #else unique_lock<mutex> __functor_lock(__get_once_mutex()); - __once_functor = std::bind(__f, __args...); + __once_functor = std::bind<void>(__f, __args...); __set_once_functor_lock_ptr(&__functor_lock); #endif (the ability to use this workaround was the main reason I fixed std::bind<void> recently) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42593