Boost C++ Libraries: Ticket #2501: upgrade_to_unique_lock doesn't compile on C++0x mode https://svn.boost.org/trac10/ticket/2501 <p> 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. </p> <p> #include &lt;boost/thread/shared_mutex.hpp&gt; </p> <p> int main() { </p> <blockquote> <p> boost::shared_mutex mtx; boost::upgrade_lock&lt;boost::shared_mutex&gt; lk(mtx); </p> </blockquote> <blockquote> <p> boost::upgrade_to_unique_lock&lt;boost::shared_mutex&gt; lk2(lk); </p> </blockquote> <p> } </p> <p> gcc spits: </p> <p> 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, </p> <blockquote> <p> from src/boost-trunk/boost/thread/mutex.hpp:16, from </p> </blockquote> <p> src/boost-trunk/boost/thread/pthread/shared_mutex.hpp:12, </p> <blockquote> <p> from src/boost-trunk/boost/thread/shared_mutex.hpp:16, from teste.cpp:1: </p> </blockquote> <p> src/boost-trunk/boost/thread/locks.hpp: In destructor 'boost::upgrade_to_unique_lock&lt;Mutex&gt;::~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&lt;boost::shared_mutex&gt;*)this)-&gt;boost::upgrade_to_unique_lock&lt;boost::shared_mutex&gt;::source </p> <h1 class="section" id="boost::movewithMutex">boost::move [with Mutex</h1> <p> boost::shared_mutex](((boost::unique_lock&lt;boost::shared_mutex&gt;&amp;&amp;)(&amp;((boost::upgrade_to_unique_lock&lt;boost::shared_mutex&gt;*)this)-&gt;boost::upgrade_to_unique_lock&lt;boost::shared_mutex&gt;::exclusive)))' src/boost-trunk/boost/thread/locks.hpp:643: note: candidates are: boost::upgrade_lock&lt;Mutex&gt; &amp; boost::upgrade_lock&lt;Mutex&gt;::operator=(boost::upgrade_lock&lt;Mutex&gt; &amp;) [with Mutex = boost::shared_mutex] src/boost-trunk/boost/thread/locks.hpp:694: note: boost::upgrade_lock&lt;Mutex&gt; &amp; boost::upgrade_lock&lt;Mutex&gt;::operator=(boost::detail::thread_move_t&lt;boost::upgrade_lock&lt;Mutex&gt; </p> <blockquote class="citation"> <p> ) [with Mutex = boost::shared_mutex] </p> </blockquote> <p> src/boost-trunk/boost/thread/locks.hpp:701: note: boost::upgrade_lock&lt;Mutex&gt;&amp; boost::upgrade_lock&lt;Mutex&gt;::operator=(boost::detail::thread_move_t&lt;boost::unique_lock&lt;Mutex&gt; </p> <blockquote class="citation"> <p> ) [with Mutex = boost::shared_mutex] </p> </blockquote> <p> src/boost-trunk/boost/thread/locks.hpp: In constructor 'boost::unique_lock&lt;Mutex&gt;::unique_lock(boost::upgrade_lock&lt;Mutex&gt;&amp;&amp;) [with Mutex = boost::shared_mutex]': src/boost-trunk/boost/thread/locks.hpp:801: instantiated from 'boost::upgrade_to_unique_lock&lt;Mutex&gt;::upgrade_to_unique_lock(boost::upgrade_lock&lt;Mutex&gt;&amp;) [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&lt;boost::shared_mutex&gt;*)this)-&gt;boost::unique_lock&lt;boost::shared_mutex&gt;::m', which is of non-class type 'boost::shared_mutex*' </p> <p> It compiles fine in non std++0x mode. </p> <p> Regards, Rodolfo Lima </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2501 Trac 1.4.3 anonymous Thu, 21 May 2009 00:39:05 GMT <link>https://svn.boost.org/trac10/ticket/2501#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2501#comment:1</guid> <description> <p> This one still does not work :( </p> </description> <category>Ticket</category> </item> <item> <author>Jonathan Wakely <jwakely.boost@…></author> <pubDate>Fri, 05 Jun 2009 15:51:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2501#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2501#comment:2</guid> <description> <p> The last error is due to a trivial typo fixed by </p> <pre class="wiki">--- 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-&gt;unlock_upgrade_and_lock(); } } #else </pre> </description> <category>Ticket</category> </item> <item> <author>Jonathan Wakely <jwakely.boost@…></author> <pubDate>Fri, 05 Jun 2009 16:03:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2501#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2501#comment:3</guid> <description> <p> 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. </p> </description> <category>Ticket</category> </item> <item> <author>Jonathan Wakely <jwakely.boost@…></author> <pubDate>Fri, 05 Jun 2009 16:34:33 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/2501 https://svn.boost.org/trac10/ticket/2501 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">2501.patch</span> </li> </ul> <p> patch for boost/thread/locks.hpp </p> Ticket Jonathan Wakely <jwakely.boost@…> Fri, 05 Jun 2009 16:43:21 GMT milestone changed; cc set https://svn.boost.org/trac10/ticket/2501#comment:4 https://svn.boost.org/trac10/ticket/2501#comment:4 <ul> <li><strong>cc</strong> <span class="trac-author">jwakely.boost@…</span> added </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.38.0</span> → <span class="trac-field-new">Boost 1.40.0</span> </li> </ul> <p> that patch against boost 1.39.0 enables C++0x move support for upgrade_lock, fixing the testcase above. </p> <p> Rodolfo, could you test it as well? It would be good to fix it for 1.40.0 </p> Ticket anonymous Sat, 05 Sep 2009 16:54:12 GMT <link>https://svn.boost.org/trac10/ticket/2501#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2501#comment:5</guid> <description> <p> Still there in 1.40 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 26 Mar 2010 02:48:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2501#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2501#comment:6</guid> <description> <p> I applied the patch on 1.42 and after some minor adjustments it worked well, IMHO it's fine to go into 1.43. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Rodolfo Lima</dc:creator> <pubDate>Mon, 12 Apr 2010 16:52:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2501#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2501#comment:7</guid> <description> <p> Any hope that it will get into 1.43? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Anthony Williams</dc:creator> <pubDate>Tue, 20 Apr 2010 15:05:59 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2501#comment:8 https://svn.boost.org/trac10/ticket/2501#comment:8 <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">fixed</span> </li> </ul> <p> Fixed on trunk </p> Ticket Braden McDaniel <braden@…> Tue, 15 Jun 2010 15:30:01 GMT cc, status, version, milestone changed; resolution deleted https://svn.boost.org/trac10/ticket/2501#comment:9 https://svn.boost.org/trac10/ticket/2501#comment:9 <ul> <li><strong>cc</strong> <span class="trac-author">braden@…</span> added </li> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost Release Branch</span> → <span class="trac-field-new">Boost Development Trunk</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.40.0</span> → <span class="trac-field-new">Boost 1.44.0</span> </li> </ul> <p> Reopening in light of <a class="ext-link" href="http://lists.boost.org/boost-users/2010/06/59926.php"><span class="icon">​</span>http://lists.boost.org/boost-users/2010/06/59926.php</a>. </p> Ticket anonymous Thu, 08 Jul 2010 16:29:39 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2501#comment:10 https://svn.boost.org/trac10/ticket/2501#comment:10 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed on trunk </p> Ticket anonymous Fri, 22 Oct 2010 15:52:30 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/2501#comment:11 https://svn.boost.org/trac10/ticket/2501#comment:11 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> This still does not compile in vs2010 on trunk 1.44.0. </p> Ticket viboes Thu, 28 Oct 2010 18:05:46 GMT type changed https://svn.boost.org/trac10/ticket/2501#comment:12 https://svn.boost.org/trac10/ticket/2501#comment:12 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Patches</span> </li> </ul> <p> Changed to Patch as patch exists. </p> Ticket viboes Sat, 03 Dec 2011 11:20:30 GMT milestone changed https://svn.boost.org/trac10/ticket/2501#comment:13 https://svn.boost.org/trac10/ticket/2501#comment:13 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.44.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket viboes Sat, 03 Dec 2011 23:35:57 GMT type changed https://svn.boost.org/trac10/ticket/2501#comment:14 https://svn.boost.org/trac10/ticket/2501#comment:14 <ul> <li><strong>type</strong> <span class="trac-field-old">Patches</span> → <span class="trac-field-new">Bugs</span> </li> </ul> Ticket viboes Sat, 03 Dec 2011 23:39:22 GMT cc changed https://svn.boost.org/trac10/ticket/2501#comment:15 https://svn.boost.org/trac10/ticket/2501#comment:15 <ul> <li><strong>cc</strong> <span class="trac-author">viboes</span> added </li> </ul> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/2501#comment:11" title="Comment 11">anonymous</a>: </p> <blockquote class="citation"> <p> This still does not compile in vs2010 on trunk 1.44.0. </p> </blockquote> <p> Hi, </p> <p> 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? </p> Ticket viboes Sun, 04 Dec 2011 23:09:14 GMT owner, status changed https://svn.boost.org/trac10/ticket/2501#comment:16 https://svn.boost.org/trac10/ticket/2501#comment:16 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">new</span> </li> </ul> <p> I have tried with MSVC 2010 and it works </p> <pre class="wiki">#include &lt;boost/thread/shared_mutex.hpp&gt; #include &lt;boost/thread/locks.hpp&gt; int main() { boost::shared_mutex mtx; boost::upgrade_lock&lt;boost::shared_mutex&gt; lk(mtx); boost::upgrade_to_unique_lock&lt;boost::shared_mutex&gt; lk2(lk); return 0; } </pre><p> Could you try again on trunk? </p> Ticket viboes Wed, 07 Dec 2011 22:45:16 GMT type changed https://svn.boost.org/trac10/ticket/2501#comment:17 https://svn.boost.org/trac10/ticket/2501#comment:17 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Support Requests</span> </li> </ul> <p> Moved to support request until resolution clarified </p> Ticket viboes Sun, 11 Dec 2011 11:39:48 GMT keywords set https://svn.boost.org/trac10/ticket/2501#comment:18 https://svn.boost.org/trac10/ticket/2501#comment:18 <ul> <li><strong>keywords</strong> move added </li> </ul> <p> The is an action point to use Boost.Move. Could we consider this as a duplicate of <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6194" title="#6194: Feature Requests: Adapt to Boost.Move (closed: fixed)">#6194</a> Adapt to Boost.Move. </p> Ticket viboes Sat, 31 Dec 2011 15:25:29 GMT status changed; resolution set; milestone deleted https://svn.boost.org/trac10/ticket/2501#comment:19 https://svn.boost.org/trac10/ticket/2501#comment:19 <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">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-deleted">To Be Determined</span> </li> </ul> <p> Closed. Please reopen if this doesn't works on trunk 1.49. </p> Ticket