Opened 10 years ago
Closed 10 years ago
#7619 closed Bugs (invalid)
Compiler error with move and packaged_task
Reported by: | anonymous | Owned by: | viboes |
---|---|---|---|
Milestone: | To Be Determined | Component: | thread |
Version: | Boost 1.51.0 | Severity: | Regression |
Keywords: | move, packaged_task, futures, io_service | Cc: |
Description
Consider the following simple code:
// mt_test.cpp #include <boost/asio.hpp> #include <boost/move/move.hpp> #include <boost/thread.hpp> int process_data() { return 1; } int main() { boost::asio::io_service io_service; boost::asio::io_service::work work(io_service); boost::packaged_task<int> task(boost::bind(&process_data)); io_service.post(boost::move(task)); }
This generates the errors (using gcc version 4.6.3 and boost 1.51.0)
g++ -I ./boost_1_51_0/ mt_test.cpp -o mt_test In file included from ./boost_1_51_0/boost/asio/io_service.hpp:767:0, from ./boost_1_51_0/boost/asio/basic_io_object.hpp:19, from ./boost_1_51_0/boost/asio/basic_socket.hpp:19, from ./boost_1_51_0/boost/asio/basic_datagram_socket.hpp:20, from ./boost_1_51_0/boost/asio.hpp:20, from mt_test.cpp:2: ./boost_1_51_0/boost/asio/impl/io_service.hpp: In member function ‘void boost::asio::io_service::post(const CompletionHandler&) [with CompletionHandler = boost::detail::thread_move_t<boost::packaged_task<int> >]’: mt_test.cpp:18:34: instantiated from here ./boost_1_51_0/boost/asio/impl/io_service.hpp:95:67: error: no match for call to ‘(boost::detail::thread_move_t<boost::packaged_task<int> >) ()’ In file included from ./boost_1_51_0/boost/asio/detail/handler_invoke_helpers.hpp:21:0, from ./boost_1_51_0/boost/asio/detail/bind_handler.hpp:20, from ./boost_1_51_0/boost/asio/detail/wrapped_handler.hpp:18, from ./boost_1_51_0/boost/asio/io_service.hpp:24, from ./boost_1_51_0/boost/asio/basic_io_object.hpp:19, from ./boost_1_51_0/boost/asio/basic_socket.hpp:19, from ./boost_1_51_0/boost/asio/basic_datagram_socket.hpp:20, from ./boost_1_51_0/boost/asio.hpp:20, from mt_test.cpp:2: ./boost_1_51_0/boost/asio/handler_invoke_hook.hpp: In function ‘void boost::asio::asio_handler_invoke(Function, ...) [with Function = boost::detail::thread_move_t<boost::packaged_task<int> >]’: ./boost_1_51_0/boost/asio/detail/handler_invoke_helpers.hpp:39:3: instantiated from ‘void boost_asio_handler_invoke_helpers::invoke(Function&, Context&) [with Function = boost::detail::thread_move_t<boost::packaged_task<int> >, Context = boost::detail::thread_move_t<boost::packaged_task<int> >]’ ./boost_1_51_0/boost/asio/detail/completion_handler.hpp:67:7: instantiated from ‘static void boost::asio::detail::completion_handler<Handler>::do_complete(boost::asio::detail::io_service_impl*, boost::asio::detail::operation*, const boost::system::error_code&, std::size_t) [with Handler = boost::detail::thread_move_t<boost::packaged_task<int> >, boost::asio::detail::io_service_impl = boost::asio::detail::task_io_service, boost::asio::detail::operation = boost::asio::detail::task_io_service_operation, std::size_t = long unsigned int]’ ./boost_1_51_0/boost/asio/detail/completion_handler.hpp:38:48: instantiated from ‘boost::asio::detail::completion_handler<Handler>::completion_handler(Handler&) [with Handler = boost::detail::thread_move_t<boost::packaged_task<int> >]’ ./boost_1_51_0/boost/asio/detail/impl/task_io_service.hpp:61:3: instantiated from ‘void boost::asio::detail::task_io_service::post(Handler) [with Handler = boost::detail::thread_move_t<boost::packaged_task<int> >]’ ./boost_1_51_0/boost/asio/impl/io_service.hpp:97:3: instantiated from ‘void boost::asio::io_service::post(const CompletionHandler&) [with CompletionHandler = boost::detail::thread_move_t<boost::packaged_task<int> >]’ mt_test.cpp:18:34: instantiated from here ./boost_1_51_0/boost/asio/handler_invoke_hook.hpp:64:3: error: no match for call to ‘(boost::detail::thread_move_t<boost::packaged_task<int> >) ()’
I thought this was solved in Ticket 4521?
Change History (3)
comment:1 by , 10 years ago
Component: | move → threads |
---|---|
Owner: | changed from | to
comment:2 by , 10 years ago
Component: | threads → thread |
---|---|
Owner: | changed from | to
Status: | new → assigned |
I don't know if io_service.post accepts a Boost.Thread emulated rvalue reference. From the compiler error I will say that no.
Boost.Thread allows to work with Boost.Move emulation when BOOST_THREAD_USES_MOVE is defined. If asio is Boost.Move compatible this could be an option.
Anyway I don't think this is a bug with Boost.Thread.
comment:3 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
This seems a Boost.Thread related problem, as Boost.Thread has several move emulation modes. Changed component from Move to Thread to reflect this.