Boost C++ Libraries: Ticket #4367: Proposed fix for test_thread_move_return.cpp https://svn.boost.org/trac10/ticket/4367 <p> Bug description: </p> <hr /> <p> The original statement in test_thread_move_return.cpp (Line 16): </p> <blockquote> <p> return boost::move(t); </p> </blockquote> <p> triggered the following error message in Sun C++ compiler (this compiler assumes that Boost has fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4305" title="#4305: Patches: out-of-date workarounds for Sun Studio compilers (closed: fixed)">#4305</a> for boost/thread/detail/thread.hpp): </p> <p> ============================================ "test_thread_move_return.cpp", line 16: Error: Cannot use boost::detail::thread_move_t&lt;boost::thread&gt; to initialize boost::thread without "boost::thread::boost::thread(const boost::thread&amp;)";. 1 Error(s) detected. ============================================ </p> <p> and the same test built with gcc-4.4.4 also failed in a similar way </p> <p> ============================================ </p> <p> 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&lt;boost::thread&gt;) ../../../boost/thread/detail/thread.hpp:150: note: boost::thread::thread() ../../../boost/thread/detail/thread.hpp:108: note: boost::thread::thread(boost::thread&amp;) ============================================ </p> <p> Sun compiler reports the failure because for the following reason. </p> <p> After finding user-defined copy constructor in boost/thread/detail/thread.hpp (line 108) thread(thread&amp;); compiler does not provide the default copy constructor with 'const' qualifier like thread(const thread&amp;). </p> <p> Then later, when compiler processes test's return statement (line 16) </p> <blockquote> <p> return boost::move(t); </p> </blockquote> <p> 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 ) </p> <p> So, the result is an error message mentioned above. </p> <p> Meantime, after replacing </p> <p> return boost::move(t); </p> <p> with </p> <p> return boost::thread(boost::move(t)); </p> <p> 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). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4367 Trac 1.4.3 sergey.sprogis@… Tue, 22 Jun 2010 19:20:09 GMT attachment set https://svn.boost.org/trac10/ticket/4367 https://svn.boost.org/trac10/ticket/4367 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test_thread_move_return.patch</span> </li> </ul> <p> this is patch for test_thread_move_return.cpp file </p> Ticket Steven Watanabe Wed, 23 Jun 2010 16:53:36 GMT component changed; owner set https://svn.boost.org/trac10/ticket/4367#comment:1 https://svn.boost.org/trac10/ticket/4367#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Anthony Williams</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket viboes Sun, 04 Dec 2011 17:03:54 GMT status changed; resolution set; milestone deleted https://svn.boost.org/trac10/ticket/4367#comment:2 https://svn.boost.org/trac10/ticket/4367#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> <li><strong>milestone</strong> <span class="trac-field-deleted">Boost 1.44.0</span> </li> </ul> <p> Well, I think that the goal is not to change the test bat the library so that it conforms to the expected test behavior. </p> <p> Allow me to close this issue, and reopen it if you don't agree. </p> Ticket