Opened 12 years ago

Closed 11 years ago

#4367 closed Bugs (invalid)

Proposed fix for test_thread_move_return.cpp

Reported by: sergey.sprogis@… Owned by: Anthony Williams
Milestone: Component: thread
Version: Boost 1.44.0 Severity: Problem
Keywords: test_thread_move_return Cc: stephen.clamage@…

Description

Bug description:


The original statement in test_thread_move_return.cpp (Line 16):

return boost::move(t);

triggered the following error message in Sun C++ compiler (this compiler assumes that Boost has fix #4305 for boost/thread/detail/thread.hpp):

============================================ "test_thread_move_return.cpp", line 16: Error: Cannot use boost::detail::thread_move_t<boost::thread> to initialize boost::thread without "boost::thread::boost::thread(const boost::thread&)";. 1 Error(s) detected. ============================================

and the same test built with gcc-4.4.4 also failed in a similar way

============================================

test_thread_move_return.cpp: In function 'boost::thread make_thread_move_return(boost::thread::id*)': test_thread_move_return.cpp:16: error: no matching function for call to 'boost::thread::thread(boost::thread)' ../../../boost/thread/detail/thread.hpp:202: note: candidates are: boost::thread::thread(boost::detail::thread_move_t<boost::thread>) ../../../boost/thread/detail/thread.hpp:150: note: boost::thread::thread() ../../../boost/thread/detail/thread.hpp:108: note: boost::thread::thread(boost::thread&) ============================================

Sun compiler reports the failure because for the following reason.

After finding user-defined copy constructor in boost/thread/detail/thread.hpp (line 108) thread(thread&); compiler does not provide the default copy constructor with 'const' qualifier like thread(const thread&).

Then later, when compiler processes test's return statement (line 16)

return boost::move(t);

a copy constructor is needed to return the temporary thread object by value from make_thread_move_return(), but there is no viable copy constructor. The existing copy constructor cannot be used because it's not allowed to bind an rvalue (the temporary thread object) to a non-const reference. (Std 2003 13.3.3.1.4:3 )

So, the result is an error message mentioned above.

Meantime, after replacing

return boost::move(t);

with

return boost::thread(boost::move(t));

compiler does not need copy constructor to create the result object, only user-defined conversion constructor thread(thread_move_t) is used (Std 2003 8.5/14).

Attachments (1)

test_thread_move_return.patch (491 bytes ) - added by sergey.sprogis@… 12 years ago.
this is patch for test_thread_move_return.cpp file

Download all attachments as: .zip

Change History (3)

by sergey.sprogis@…, 12 years ago

this is patch for test_thread_move_return.cpp file

comment:1 by Steven Watanabe, 12 years ago

Component: Nonethread
Owner: set to Anthony Williams

comment:2 by viboes, 11 years ago

Milestone: Boost 1.44.0
Resolution: invalid
Status: newclosed

Well, I think that the goal is not to change the test bat the library so that it conforms to the expected test behavior.

Allow me to close this issue, and reopen it if you don't agree.

Note: See TracTickets for help on using tickets.