|
Boost : |
Subject: Re: [boost] [thread] SEVERE bug on packaged_task constructor in C++11 mode.
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-05-21 15:58:44
Le 21/05/13 08:24, Vicente J. Botet Escriba a écrit :
> Hi,
>
> There is a severe bug in packaged_task constructor when compiling in
> C++11 mode and giving a copyable functor as parameter, as reported in
> https://svn.boost.org/trac/boost/ticket/8596. I believe that this is
> not a regression, this have never worked.
>
> Until I find a fix, the packaged_task could be used only with free
> functions and with movable functors when compiling in C++11 mode.
>
>
I think that i have found why this was not working an fix it. The
forwarding from packaged task to the internal class was incorrect.
The following patch fix the example in ticket and works for all the
ts_packaged_task regression tests.
I'll commit this on trunk once the whole regression tests finish and pass.
Best,
Vicente
svn diff detail/config.hpp future.hpp
Index: detail/config.hpp
===================================================================
--- detail/config.hpp (revision 84336)
+++ detail/config.hpp (working copy)
@@ -13,8 +13,6 @@
#include <boost/thread/detail/platform.hpp>
//#define BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
-
-
// ATTRIBUTE_MAY_ALIAS
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) > 302 \
@@ -95,9 +93,9 @@
#endif
/// RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
-#if defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_MSVC
+//#if defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_MSVC
#define BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
-#endif
+//#endif
// Default version
#if !defined BOOST_THREAD_VERSION
Index: future.hpp
===================================================================
--- future.hpp (revision 84336)
+++ future.hpp (working copy)
@@ -2275,18 +2275,12 @@
task_object(task_object&);
public:
F f;
-#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::forward<F>(f_))
- {}
-#else
task_object(F const& f_):
f(f_)
{}
task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::move(f_)) // TODO forward
+ f(boost::move(f_))
{}
-#endif
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &&
defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
@@ -2837,12 +2831,11 @@
#endif
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class F>
- explicit packaged_task(BOOST_THREAD_RV_REF(F) f
+ explicit packaged_task(BOOST_THREAD_FWD_REF(F) f
, typename disable_if<is_same<typename decay<F>::type,
packaged_task>, dummy* >::type=0
)
{
- //typedef typename remove_cv<typename
remove_reference<F>::type>::type FR;
- typedef F FR;
+ typedef typename remove_cv<typename
remove_reference<F>::type>::type FR;
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
typedef detail::task_object<FR,R(ArgTypes...)>
task_object_type;
@@ -2921,10 +2914,9 @@
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
template <class F, class Allocator>
- packaged_task(boost::allocator_arg_t, Allocator a,
BOOST_THREAD_RV_REF(F) f)
+ packaged_task(boost::allocator_arg_t, Allocator a,
BOOST_THREAD_FWD_REF(F) f)
{
- //typedef typename remove_cv<typename
remove_reference<F>::type>::type FR;
- typedef F FR;
+ typedef typename remove_cv<typename
remove_reference<F>::type>::type FR;
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
typedef detail::task_object<FR,R(ArgTypes...)> task_object_type;
iMac-de-Vicente-Botet-Escriba:thread viboes$
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk