Boost C++ Libraries: Ticket #4426: invalid init of reference with gcc 4.5, 4.6 with -std=c++0x https://svn.boost.org/trac10/ticket/4426 <p> see <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4396" title="#4396: Bugs: thread does not compile with gcc 4.5 and -std=gnu++0x (closed: fixed)">#4396</a> - for the threads library this problem is now solved. </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> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4426 Trac 1.4.3 itsme@… Wed, 21 Jul 2010 08:55:27 GMT <link>https://svn.boost.org/trac10/ticket/4426#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4426#comment:1</guid> <description> <p> see <a class="changeset" href="https://svn.boost.org/trac10/changeset/62717" title="Added static cast in move of upgrade_lock to work with MSVC10 and g++4.5 ">[62717]</a> </p> <p> this is the patch to make ipc build with gcc4.5 </p> <pre class="wiki"> Index: boost/interprocess/detail/move.hpp =================================================================== --- boost/interprocess/detail/move.hpp (revision 64212) +++ boost/interprocess/detail/move.hpp (working copy) @@ -355,7 +355,7 @@ #else template &lt;class T&gt; inline typename remove_reference&lt;T&gt;::type&amp;&amp; move(T&amp;&amp; t) -{ return t; } +{ return static_cast&lt;typename remove_reference&lt;T&gt;::type&amp;&amp;&gt;(t); } #endif ////////////////////////////////////////////////////////////////////////////// </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Thu, 26 Aug 2010 10:30:06 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/4426#comment:2 https://svn.boost.org/trac10/ticket/4426#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">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.44.0</span> → <span class="trac-field-new">Boost-1.45.0</span> </li> </ul> <p> Fixed for Boost 1.45 in release branch </p> Ticket