Opened 6 years ago

Closed 6 years ago

#6141 closed Bugs (fixed)

Compilation error when boost.thread and boost.move are used together

Reported by: admin@… Owned by: viboes
Milestone: Boost 1.49.0 Component: thread
Version: Boost 1.48.0 Severity: Showstopper
Keywords: move Cc: nathan@…, viboes


Thread component has the definition "move" in boost/thread/detail/move.hpp, but new version of library contains the global description of "move" semantics in boost.move. It gives the conflict at compilation "ambiguous call to overloaded function". It is a code reproduces the given problem.

#include <boost/thread.hpp>
#include <boost/move/move.hpp>

void func()
    boost::shared_mutex mutex;
    boost::upgrade_lock<boost::shared_mutex>           _upgrade_lock(mutex);
    boost::upgrade_to_unique_lock<boost::shared_mutex> _unique_lock(_upgrade_lock); // compilation error

Attachments (0)

Change History (14)

comment:1 Changed 6 years ago by nathan@…

Cc: nathan@… added

comment:2 Changed 6 years ago by anonymous

Looks like I have the same problem (boost 1.48, MSVC2008):

enc_frame_queue.cpp:74: error: C2664: 'boost::upgrade_to_unique_lock<Mutex>::upgrade_to_unique_lock(boost::upgrade_to_unique_lock<Mutex> &)' : cannot convert parameter 1 from 'boost::shared_lock<Mutex>' to 'boost::upgrade_to_unique_lock<Mutex> &' with [



comment:3 Changed 6 years ago by anonymous

Yes, same issue here.

comment:4 Changed 6 years ago by blake-r@…

--- a/locks.hpp	2011-12-05 12:26:11.650309054 +0400
+++ b/locks.hpp	2011-12-05 12:27:25.905311415 +0400
@@ -923,13 +923,13 @@
         upgrade_to_unique_lock& operator=(upgrade_to_unique_lock&);
         explicit upgrade_to_unique_lock(upgrade_lock<Mutex>& m_):
-            source(&m_),exclusive(move(*source))
+            source(&m_),exclusive(move(detail::thread_move_t<upgrade_lock<Mutex> >(*source)))
-                *source=move(exclusive);
+                *source=move(detail::thread_move_t<unique_lock<Mutex> >(exclusive));

comment:5 Changed 6 years ago by viboes

Cc: viboes added
Keywords: move added

The is an action point to use Boost.Move. Could we consider this as a duplicate of #6194 Adapt to Boost.Move.

comment:6 Changed 6 years ago by anonymous

That's fine if you want to fix it when addressing #6194 - but this bug is actually a regression...code that used to work in 1.47.0 no longer even compiles in 1.48.0. It prevents you from using boost/thread/locks.hpp in conjunction with boost/unordered_map.hpp - since unordered map uses Boost::Move and thread locks use the other Boost::Move.

comment:7 Changed 6 years ago by anonymous

In other words, I think this issue should actually be "upgraded" to a regression - instead of "downgraded" to a feature request (which #6194 is...)

comment:8 Changed 6 years ago by Hartmut Kaiser

Severity: ProblemShowstopper

comment:9 Changed 6 years ago by Hartmut Kaiser

Milestone: To Be DeterminedBoost 1.49.0

comment:10 Changed 6 years ago by viboes

The following patch in boost/move/move.hpp allows to avoid the issue provided Boost.Thread adds the needed specializations for has_move_emulation_enabled_aux.

 svn diff
Index: move.hpp
--- move.hpp	(revision 75884)
+++ move.hpp	(working copy)
@@ -280,6 +280,10 @@
       : BOOST_MOVE_BOOST_NS::integral_constant<bool, false>
+   template <class T>
+   struct has_move_emulation_enabled_aux 
+     : has_move_emulation_enabled<T> {};
    template <class T> 
    struct has_nothrow_move
       : public BOOST_MOVE_BOOST_NS::integral_constant<bool, false>
@@ -290,8 +294,9 @@
    //                            move()
    template <class T>
-   typename BOOST_MOVE_BOOST_NS::disable_if<has_move_emulation_enabled<T>, T&>::type move(T& x)
+   typename BOOST_MOVE_BOOST_NS::disable_if<has_move_emulation_enabled_aux<T>, T&>::type move(T& x)
       return x;

Waiting for Ion response to see if he accepts this patch.

comment:11 Changed 6 years ago by viboes

Boost.Move patch committed

svn ci move.hpp -m "Move/Thread?: Added type tait so that #6141 - Compilation error when boost.thread and boost.move are used together - can be solved on the Boost.Thread side"

Sending move.hpp Transmitting file data . Committed revision #76271.

comment:12 Changed 6 years ago by viboes

Committed in trunk at revision #76277 Boost.Thread part.

comment:13 Changed 6 years ago by viboes

Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:14 Changed 6 years ago by viboes

Resolution: fixed
Status: assignedclosed

(In [76346]) Thread: merge from trunk to fix #6141, #5594, #5040 and #5502.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain viboes.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.