Opened 14 years ago
Closed 11 years ago
#2501 closed Support Requests (fixed)
upgrade_to_unique_lock doesn't compile on C++0x mode
Reported by: | Rodolfo Lima | Owned by: | viboes |
---|---|---|---|
Milestone: | Component: | thread | |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | move | Cc: | jwakely.boost@…, braden@…, viboes |
Description
The following code doesn't compile with gcc-4.3.2 (and gcc-4.4.0), and boost-1.36 (and boost-1.37) when using -std=c++0x on linux.
#include <boost/thread/shared_mutex.hpp>
int main() {
boost::shared_mutex mtx; boost::upgrade_lock<boost::shared_mutex> lk(mtx);
boost::upgrade_to_unique_lock<boost::shared_mutex> lk2(lk);
}
gcc spits:
g++-4.4.0-alpha20081003 -std=c++0x -I src/boost-trunk teste.cpp -o teste In file included from src/boost-trunk/boost/thread/pthread/mutex.hpp:11,
from src/boost-trunk/boost/thread/mutex.hpp:16, from
src/boost-trunk/boost/thread/pthread/shared_mutex.hpp:12,
from src/boost-trunk/boost/thread/shared_mutex.hpp:16, from teste.cpp:1:
src/boost-trunk/boost/thread/locks.hpp: In destructor 'boost::upgrade_to_unique_lock<Mutex>::~upgrade_to_unique_lock() [with Mutex = boost::shared_mutex]': teste.cpp:8: instantiated from here src/boost-trunk/boost/thread/locks.hpp:807: error: no match for 'operator=' in '*((boost::upgrade_to_unique_lock<boost::shared_mutex>*)this)->boost::upgrade_to_unique_lock<boost::shared_mutex>::source
boost::move [with Mutex
boost::shared_mutex](((boost::unique_lock<boost::shared_mutex>&&)(&((boost::upgrade_to_unique_lock<boost::shared_mutex>*)this)->boost::upgrade_to_unique_lock<boost::shared_mutex>::exclusive)))' src/boost-trunk/boost/thread/locks.hpp:643: note: candidates are: boost::upgrade_lock<Mutex> & boost::upgrade_lock<Mutex>::operator=(boost::upgrade_lock<Mutex> &) [with Mutex = boost::shared_mutex] src/boost-trunk/boost/thread/locks.hpp:694: note: boost::upgrade_lock<Mutex> & boost::upgrade_lock<Mutex>::operator=(boost::detail::thread_move_t<boost::upgrade_lock<Mutex>
) [with Mutex = boost::shared_mutex]
src/boost-trunk/boost/thread/locks.hpp:701: note: boost::upgrade_lock<Mutex>& boost::upgrade_lock<Mutex>::operator=(boost::detail::thread_move_t<boost::unique_lock<Mutex>
) [with Mutex = boost::shared_mutex]
src/boost-trunk/boost/thread/locks.hpp: In constructor 'boost::unique_lock<Mutex>::unique_lock(boost::upgrade_lock<Mutex>&&) [with Mutex = boost::shared_mutex]': src/boost-trunk/boost/thread/locks.hpp:801: instantiated from 'boost::upgrade_to_unique_lock<Mutex>::upgrade_to_unique_lock(boost::upgrade_lock<Mutex>&) [with Mutex = boost::shared_mutex]' teste.cpp:8: instantiated from here src/boost-trunk/boost/thread/locks.hpp:775: error: request for member 'unlock_upgrade_and_lock' in '((boost::unique_lock<boost::shared_mutex>*)this)->boost::unique_lock<boost::shared_mutex>::m', which is of non-class type 'boost::shared_mutex*'
It compiles fine in non std++0x mode.
Regards, Rodolfo Lima
Attachments (1)
Change History (20)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
The last error is due to a trivial typo fixed by
--- boost-1_39/boost/thread/locks.hpp +++ boost/thread/locks.hpp @@ -772,7 +772,7 @@ other.is_locked=false; if(is_locked) { - m.unlock_upgrade_and_lock(); + m->unlock_upgrade_and_lock(); } } #else
comment:3 by , 13 years ago
The second error is because upgrade_lock has no handling for the case when BOOST_HAS_RVALUE_REFS is defined. In that case boost::move() returns an rvalue reference rather than a boost::thread_move_t, but upgrade_lock can only handle the move wrapper, not an rvalue reference.
comment:4 by , 13 years ago
Cc: | added |
---|---|
Milestone: | Boost 1.38.0 → Boost 1.40.0 |
that patch against boost 1.39.0 enables C++0x move support for upgrade_lock, fixing the testcase above.
Rodolfo, could you test it as well? It would be good to fix it for 1.40.0
comment:6 by , 13 years ago
I applied the patch on 1.42 and after some minor adjustments it worked well, IMHO it's fine to go into 1.43.
comment:9 by , 12 years ago
Cc: | added |
---|---|
Milestone: | Boost 1.40.0 → Boost 1.44.0 |
Resolution: | fixed |
Status: | closed → reopened |
Version: | Boost Release Branch → Boost Development Trunk |
Reopening in light of http://lists.boost.org/boost-users/2010/06/59926.php.
follow-up: 15 comment:11 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
This still does not compile in vs2010 on trunk 1.44.0.
comment:13 by , 11 years ago
Milestone: | Boost 1.44.0 → To Be Determined |
---|
comment:14 by , 11 years ago
Type: | Patches → Bugs |
---|
comment:15 by , 11 years ago
Cc: | added |
---|
Replying to anonymous:
This still does not compile in vs2010 on trunk 1.44.0.
Hi,
This ticket was for gcc-4.3.2 (and gcc-4.4.0). Please, even if this is an old ticket, could you post the errors you found now and post them here or even create another ticket and close this one?
comment:16 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
I have tried with MSVC 2010 and it works
#include <boost/thread/shared_mutex.hpp> #include <boost/thread/locks.hpp> int main() { boost::shared_mutex mtx; boost::upgrade_lock<boost::shared_mutex> lk(mtx); boost::upgrade_to_unique_lock<boost::shared_mutex> lk2(lk); return 0; }
Could you try again on trunk?
comment:17 by , 11 years ago
Type: | Bugs → Support Requests |
---|
Moved to support request until resolution clarified
comment:18 by , 11 years ago
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:19 by , 11 years ago
Milestone: | To Be Determined |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Closed. Please reopen if this doesn't works on trunk 1.49.
This one still does not work :(