Boost C++ Libraries: Ticket #10165: Error when adding an edge in an adjacency list https://svn.boost.org/trac10/ticket/10165 <p> I encountered a regression using the boost graph library, but I am not exactly sure what caused the regression since the file concerned has not changed for a couple of months. </p> <p> Here is a little code snippet showing the bug. I am using Visual Studio 2013, 64 bits. The bug occurs both in debug and release mode : </p> <p> #include &lt;boost/graph/adjacency_list.hpp&gt; #include &lt;boost/graph/graph_traits.hpp&gt; #include &lt;iostream&gt; </p> <p> void main() { </p> <blockquote> <p> typedef boost::adjacency_list&lt;boost::vecS, boost::vecS, boost::directedS, int, int&gt; Graph; Graph g(2); auto result = add_edge(0, 1, g); boost::graph_traits&lt;Graph&gt;::edge_iterator ei, ei_end; boost::tie(ei, ei_end) = boost::edges(g); std::cout &lt;&lt; "edge target is: " &lt;&lt; (*ei).m_target &lt;&lt; std::endl; </p> </blockquote> <p> } </p> <p> The result is an uninitialized value of the target vertex: 14829735431805717965. </p> <p> After investigation of the issue, it seems that the problem lies in adjacency_list.hpp, pushing the newly created edge into the container, it makes a copy from a rvalue reference. This copy does move the property unique_ptr but does not copy the target value of the edge. </p> <p> I used the qttqched patch to fix this, it simply consists in copying the m_target propoerty of the edge along the m_property. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10165 Trac 1.4.3 ernest.galbrun@… Tue, 01 Jul 2014 14:32:17 GMT attachment set https://svn.boost.org/trac10/ticket/10165 https://svn.boost.org/trac10/ticket/10165 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">0001-changed-the-copy-from-rvalue-reference-to-copy-m_taa.patch</span> </li> </ul> <p> p </p> Ticket ernest.galbrun@… Tue, 01 Jul 2014 14:32:21 GMT attachment set https://svn.boost.org/trac10/ticket/10165 https://svn.boost.org/trac10/ticket/10165 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">0001-changed-the-copy-from-rvalue-reference-to-copy-m_taa.2.patch</span> </li> </ul> <p> patch proposing fix </p> Ticket Eric Niebler Wed, 30 Jul 2014 21:22:31 GMT <link>https://svn.boost.org/trac10/ticket/10165#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10165#comment:1</guid> <description> <p> The following pull request (currently merged to the develop branch, but not master) has fixed this issue for me. Can you please update and confirm that your issue is fixed? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Wed, 30 Jul 2014 22:36:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10165#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10165#comment:2</guid> <description> <p> The pull request is actually this one: <a class="ext-link" href="https://github.com/boostorg/graph/pull/14"><span class="icon">​</span>https://github.com/boostorg/graph/pull/14</a> </p> </description> <category>Ticket</category> </item> <item> <author>ernest.galbrun@…</author> <pubDate>Thu, 31 Jul 2014 09:23:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10165#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10165#comment:3</guid> <description> <p> Yes it works, thanks for the fix. I think it deserves to be pushed quickly in the release branch since right now the graph library does not work at all with visual studio. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Mon, 04 Aug 2014 02:25:42 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10165#comment:4 https://svn.boost.org/trac10/ticket/10165#comment:4 <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 for 1.56. </p> Ticket