Boost C++ Libraries: Ticket #4396: thread does not compile with gcc 4.5 and -std=gnu++0x https://svn.boost.org/trac10/ticket/4396 <p> the easiest way to see the problem is </p> <p> cp boost-1_42/boost/thread.hpp . c++ -pthread -O2 -Iboost-1_42/ -std=gnu++0x thread.hpp In file included from boost-1_42/boost/thread/thread.hpp:22:0, </p> <blockquote> <p> from thread.hpp:13: </p> </blockquote> <p> boost-1_42/boost/thread/detail/thread.hpp: In function 'boost::thread&amp;&amp; boost::move(boost::thread&amp;&amp;)': boost-1_42/boost/thread/detail/thread.hpp:349:16: error: invalid initialization of reference of type 'boost::thread&amp;&amp;' from expression of type 'boost::thread' In file included from boost-1_42/boost/thread/detail/thread_heap_alloc.hpp:17:0, </p> <blockquote> <p> from boost-1_42/boost/thread/detail/thread.hpp:13, from boost-1_42/boost/thread/thread.hpp:22, from thread.hpp:13: </p> </blockquote> <p> boost-1_42/boost/thread/pthread/thread_heap_alloc.hpp: In function 'T* boost::detail::heap_new(A1&amp;&amp;) [with T = boost::detail::thread_data&lt;void (*)()&gt;, A1 = void (*&amp;)()]': boost-1_42/boost/thread/detail/thread.hpp:130:95: instantiated from here boost-1_42/boost/thread/pthread/thread_heap_alloc.hpp:24:47: error: cannot bind 'void (*)()' lvalue to 'void (*&amp;&amp;)()' boost-1_42/boost/thread/detail/thread.hpp:43:13: error: initializing argument 1 of 'boost::detail::thread_data&lt;F&gt;::thread_data(F&amp;&amp;) [with F = void (*)()]' In file included from boost-1_42/boost/thread/pthread/mutex.hpp:11:0, </p> <blockquote> <p> from boost-1_42/boost/thread/mutex.hpp:16, from boost-1_42/boost/thread/pthread/thread_data.hpp:12, from boost-1_42/boost/thread/thread.hpp:17, from thread.hpp:13: </p> </blockquote> <p> boost-1_42/boost/thread/locks.hpp: In member function 'boost::unique_lock&lt;Mutex&gt;&amp; boost::unique_lock&lt;Mutex&gt;::operator=(boost::unique_lock&lt;Mutex&gt;&amp;&amp;) [with Mutex = boost::mutex, boost::unique_lock&lt;Mutex&gt; = boost::unique_lock&lt;boost::mutex&gt;]': boost-1_42/boost/thread/future.hpp:414:91: instantiated from here boost-1_42/boost/thread/locks.hpp:269:13: error: cannot bind 'boost::unique_lock&lt;boost::mutex&gt;' lvalue to 'boost::unique_lock&lt;boost::mutex&gt;&amp;&amp;' boost-1_42/boost/thread/locks.hpp:279:14: error: initializing argument 1 of 'void boost::unique_lock&lt;Mutex&gt;::swap(boost::unique_lock&lt;Mutex&gt;&amp;&amp;) [with Mutex = boost::mutex, boost::unique_lock&lt;Mutex&gt; = boost::unique_lock&lt;boost::mutex&gt;]' </p> <p> c++ being either GNU C++ (GCC) version 4.5.0 (x86_64-unknown-linux-gnu) </p> <blockquote> <p> compiled by GNU C version 4.5.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 </p> </blockquote> <p> or GNU C++ (GCC) version 4.6.0 20100408 (experimental) (x86_64-unknown-linux-gnu) </p> <blockquote> <p> compiled by GNU C version 4.6.0 20100408 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4396 Trac 1.4.3 Steven Watanabe Sun, 11 Jul 2010 02:00:38 GMT component changed; owner set https://svn.boost.org/trac10/ticket/4396#comment:1 https://svn.boost.org/trac10/ticket/4396#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 itsme@… Mon, 12 Jul 2010 08:38:50 GMT <link>https://svn.boost.org/trac10/ticket/4396#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4396#comment:2</guid> <description> <p> it is not only in the thread library, the boost/interprocess library has a similar error (invalid initialization of reference type) </p> <p> this code builds fine with msvc2010 </p> <p> with gcc 4.6 beta i get the same error. </p> <p> without the -std=c++0x option it compiles ok </p> <p> with boost_1_40_0 and boost_1_39_0 i also get the same error. </p> <pre class="wiki">echo '#include "boost/interprocess/file_mapping.hpp"' &gt; xinc.cpp g++-mp-4.5 -I /opt/local/include/ xinc.cpp -std=c++0x In file included from /opt/local/include/boost/interprocess/detail/utilities.hpp:25:0, from /opt/local/include/boost/interprocess/file_mapping.hpp:19, from xinc.cpp:1: /opt/local/include/boost/interprocess/detail/move.hpp: In function 'typename boost::remove_reference&lt;T&gt;::type&amp;&amp; boost::interprocess::move(T&amp;&amp;) [with T = boost::interprocess::file_mapping&amp;, typename boost::remove_reference&lt;T&gt;::type = boost::interprocess::file_mapping]': /opt/local/include/boost/interprocess/file_mapping.hpp:62:55: instantiated from here /opt/local/include/boost/interprocess/detail/move.hpp:342:11: error: invalid initialization of reference of type 'boost::remove_reference&lt;boost::interprocess::file_mapping&amp;&gt;::type&amp;&amp;' from expression of type 'boost::interprocess::file_mapping' </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 12 Jul 2010 08:41:59 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4396#comment:3 https://svn.boost.org/trac10/ticket/4396#comment:3 <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> Trunk compiles with gcc 4.5 in -std=c++0x mode. </p> Ticket itsme@… Mon, 12 Jul 2010 09:17:08 GMT <link>https://svn.boost.org/trac10/ticket/4396#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4396#comment:4</guid> <description> <p> i cannot confirm that. </p> <p> also with trunk, revision 63919 i get the above error with gcc 4.5 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 12 Jul 2010 09:42:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4396#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4396#comment:5</guid> <description> <p> Clarification: Boost.Thread on trunk (revision 63919) compiles with gcc 4.5 in -std=c++0x mode (tested on Ubuntu 9.10/x86_64 with gcc-4.5 (Ubuntu 4.5-20100227-1gezakovacs~karmic1) 4.5.0 20100227 (experimental) [trunk revision 157109]) </p> </description> <category>Ticket</category> </item> <item> <author>itsme@…</author> <pubDate>Mon, 12 Jul 2010 10:10:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4396#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4396#comment:6</guid> <description> <p> i filed a new ticket ( <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4426" title="#4426: Bugs: invalid init of reference with gcc 4.5, 4.6 with -std=c++0x (closed: fixed)">#4426</a> ) for component interprocess </p> <p> what commit fixed the problem for boost.thread ? </p> </description> <category>Ticket</category> </item> </channel> </rss>