Opened 8 years ago
Closed 8 years ago
#10165 closed Bugs (fixed)
Error when adding an edge in an adjacency list
Reported by: | Owned by: | Jeremiah Willcock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | graph |
Version: | Boost Release Branch | Severity: | Regression |
Keywords: | Cc: |
Description
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.
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 :
#include <boost/graph/adjacency_list.hpp> #include <boost/graph/graph_traits.hpp> #include <iostream>
void main() {
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, int, int> Graph; Graph g(2); auto result = add_edge(0, 1, g); boost::graph_traits<Graph>::edge_iterator ei, ei_end; boost::tie(ei, ei_end) = boost::edges(g); std::cout << "edge target is: " << (*ei).m_target << std::endl;
}
The result is an uninitialized value of the target vertex: 14829735431805717965.
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.
I used the qttqched patch to fix this, it simply consists in copying the m_target propoerty of the edge along the m_property.
Attachments (2)
Change History (6)
by , 8 years ago
Attachment: | 0001-changed-the-copy-from-rvalue-reference-to-copy-m_taa.patch added |
---|
by , 8 years ago
Attachment: | 0001-changed-the-copy-from-rvalue-reference-to-copy-m_taa.2.patch added |
---|
patch proposing fix
comment:1 by , 8 years ago
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?
comment:2 by , 8 years ago
The pull request is actually this one: https://github.com/boostorg/graph/pull/14
comment:3 by , 8 years ago
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