Boost C++ Libraries: Ticket #8791: successfull compilation depends on header order in Graph https://svn.boost.org/trac10/ticket/8791 <p> From time to time program cannot be compiled due to incorrect order of headers. It always takes some time to resolve correct order of headers. I found also very simple example, see attachment. Example does not compile until transitive_closure.hpp is moved up. </p> <p> <em> compiled on Linux 64:<br /> </em> g++ -std=c++0x -Iboost/include -frounding-math -O2 x.cpp -o x.exe<br /> </p> <p> #include &lt;boost/graph/adjacency_list.hpp&gt;<br /> #include &lt;boost/graph/graph_utility.hpp&gt;<br /> #include &lt;boost/graph/transitive_closure.hpp&gt; <em> must be on top<br /> </em></p> <p> int main(int, char *[]) {<br /> </p> <blockquote> <p> using namespace boost;<br /> typedef adjacency_list &lt; listS, vecS, directedS &gt; G;<br /> G g;<br /> add_edge(0,1, g);<br /> adjacency_list &lt;&gt; tc;<br /> transitive_closure(g, tc);<br /> print_graph(tc);<br /> return 0;<br /> </p> </blockquote> <p> }<br /> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8791 Trac 1.4.3 karnigen <karnigen@…> Sun, 07 Jul 2013 11:42:45 GMT attachment set https://svn.boost.org/trac10/ticket/8791 https://svn.boost.org/trac10/ticket/8791 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">x.cpp</span> </li> </ul> Ticket Jeremiah Willcock Sun, 07 Jul 2013 16:50:25 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8791#comment:1 https://svn.boost.org/trac10/ticket/8791#comment:1 <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> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/84976" title="Changed to use adjacency_list for temporary graph, avoiding ADL issues ...">[84976]</a>) Changed to use adjacency_list for temporary graph, avoiding ADL issues with vector_as_graph; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8791" title="#8791: Bugs: successfull compilation depends on header order in Graph (closed: fixed)">#8791</a> </p> Ticket Albert Gil <albert.gil@…> Wed, 08 Oct 2014 11:39:52 GMT <link>https://svn.boost.org/trac10/ticket/8791#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8791#comment:2</guid> <description> <p> Hi, </p> <p> I've a very similar problem with <code>boost/graph/dijkstra_shortest_paths.hpp</code>, it should be included before <code>boost/graph/strong_components.hpp</code>... could it be related also to this ADL problem? </p> <p> Also I've a very similar problem with <code>boost/graph/edmonds_karp_max_flow.hpp</code>, but I can't make it compile at all (changing headers order) on 1.55, it works on 1.50. </p> <p> The original code is not mine, I'm not an expert on boost.graph, but the simpler test case I've been able to create from the original to replicate the error for <code>boost/graph/edmonds_karp_max_flow.hpp</code> is: </p> <pre class="wiki">#include &lt;boost/graph/edmonds_karp_max_flow.hpp&gt; #include &lt;boost/graph/adjacency_list.hpp&gt; typedef boost::adjacency_list_traits &lt; boost::listS, boost::vecS, boost::bidirectionalS &gt; Traits; struct NodeMaxFlowProperties { boost::default_color_type color; double distance; Traits::edge_descriptor predecessor; NodeMaxFlowProperties() : color(boost::white_color), predecessor() {} }; struct EdgeMaxFlowProperties { double capacity; double residual_capacity; Traits::edge_descriptor reverse_edge; EdgeMaxFlowProperties() : capacity(0), residual_capacity(0), reverse_edge() {} }; typedef boost::adjacency_list&lt; boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties &gt; Graph; typedef boost::graph_traits&lt;Graph&gt;::vertex_descriptor Node; int main () { Graph graph; Node source; Node sink; boost::edmonds_karp_max_flow(graph, source, sink , boost::capacity_map( get(&amp;EdgeMaxFlowProperties::capacity, graph)). residual_capacity_map( get(&amp;EdgeMaxFlowProperties::residual_capacity, graph)). reverse_edge_map( get(&amp;EdgeMaxFlowProperties::reverse_edge, graph)). color_map( get(&amp;NodeMaxFlowProperties::color, graph))); } </pre><p> The GCC error looks like: </p> <pre class="wiki">/usr/local/include/boost/graph/detail/adjacency_list.hpp: In instantiation of 'struct boost::detail::adj_list_any_edge_pmap::bind_&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, EdgeMaxFlowProperties, boost::edge_capacity_t&gt;': /usr/local/include/boost/graph/detail/adjacency_list.hpp:2683:12: required from 'struct boost::detail::adj_list_choose_edge_pmap&lt;boost::edge_capacity_t, boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, EdgeMaxFlowProperties&gt;' /usr/local/include/boost/graph/detail/adjacency_list.hpp:2688:14: required from 'struct boost::detail::adj_list_edge_property_selector::bind_&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, EdgeMaxFlowProperties, boost::edge_capacity_t&gt;' /usr/local/include/boost/graph/properties.hpp:208:12: required from 'struct boost::detail::edge_property_map&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::edge_capacity_t&gt;' /usr/local/include/boost/graph/properties.hpp:228:10: required from 'struct boost::property_map&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::edge_capacity_t, void&gt;' /usr/local/include/boost/mpl/eval_if.hpp:38:31: recursively required from 'struct boost::mpl::eval_if&lt;mpl_::bool_&lt;true&gt;, boost::detail::const_type_as_type&lt;boost::property_map&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::edge_capacity_t, void&gt; &gt;, boost::property_map&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::edge_capacity_t, void&gt; &gt;' /usr/local/include/boost/mpl/eval_if.hpp:38:31: required from 'struct boost::mpl::eval_if&lt;boost::is_same&lt;boost::param_not_found, boost::param_not_found&gt;, boost::mpl::eval_if&lt;mpl_::bool_&lt;true&gt;, boost::detail::const_type_as_type&lt;boost::property_map&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::edge_capacity_t, void&gt; &gt;, boost::property_map&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::edge_capacity_t, void&gt; &gt;, boost::mpl::identity&lt;boost::param_not_found&gt; &gt;' /usr/local/include/boost/graph/named_function_params.hpp:269:12: required from 'struct boost::detail::choose_impl_result&lt;mpl_::bool_&lt;true&gt;, boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::param_not_found, boost::edge_capacity_t&gt;' /usr/local/include/boost/graph/named_function_params.hpp:326:156: required from 'struct boost::detail::edge_capacity_value&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::vec_adj_list_vertex_property_map&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;*, boost::default_color_type, boost::default_color_type&amp;, boost::default_color_type NodeMaxFlowProperties::*&gt;, boost::vertex_color_t, boost::bgl_named_params&lt;boost::adj_list_edge_property_map&lt;boost::bidirectional_tag, boost::detail::edge_desc_impl&lt;boost::bidirectional_tag, unsigned int&gt;, boost::detail::edge_desc_impl&lt;boost::bidirectional_tag, unsigned int&gt;&amp;, unsigned int, EdgeMaxFlowProperties, boost::detail::edge_desc_impl&lt;boost::bidirectional_tag, unsigned int&gt; EdgeMaxFlowProperties::*&gt;, boost::edge_reverse_t, boost::bgl_named_params&lt;boost::adj_list_edge_property_map&lt;boost::bidirectional_tag, double, double&amp;, unsigned int, EdgeMaxFlowProperties, double EdgeMaxFlowProperties::*&gt;, boost::edge_residual_capacity_t, boost::bgl_named_params&lt;boost::adj_list_edge_property_map&lt;boost::bidirectional_tag, double, double&amp;, unsigned int, EdgeMaxFlowProperties, double EdgeMaxFlowProperties::*&gt;, boost::edge_capacity_t, boost::no_property&gt; &gt; &gt; &gt;' /usr/local/include/boost/graph/edmonds_karp_max_flow.hpp:223:3: required by substitution of 'template&lt;class Graph, class P, class T, class R&gt; typename boost::detail::edge_capacity_value::type boost::edmonds_karp_max_flow(Graph&amp;, typename boost::graph_traits&lt;IncidenceGraph&gt;::vertex_descriptor, typename boost::graph_traits&lt;IncidenceGraph&gt;::vertex_descriptor, const boost::bgl_named_params&lt;T, Tag, Base&gt;&amp;) [with Graph = boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;; P = boost::vec_adj_list_vertex_property_map&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;*, boost::default_color_type, boost::default_color_type&amp;, boost::default_color_type NodeMaxFlowProperties::*&gt;; T = boost::vertex_color_t; R = boost::bgl_named_params&lt;boost::adj_list_edge_property_map&lt;boost::bidirectional_tag, boost::detail::edge_desc_impl&lt;boost::bidirectional_tag, unsigned int&gt;, boost::detail::edge_desc_impl&lt;boost::bidirectional_tag, unsigned int&gt;&amp;, unsigned int, EdgeMaxFlowProperties, boost::detail::edge_desc_impl&lt;boost::bidirectional_tag, unsigned int&gt; EdgeMaxFlowProperties::*&gt;, boost::edge_reverse_t, boost::bgl_named_params&lt;boost::adj_list_edge_property_map&lt;boost::bidirectional_tag, double, double&amp;, unsigned int, EdgeMaxFlowProperties, double EdgeMaxFlowProperties::*&gt;, boost::edge_residual_capacity_t, boost::bgl_named_params&lt;boost::adj_list_edge_property_map&lt;boost::bidirectional_tag, double, double&amp;, unsigned int, EdgeMaxFlowProperties, double EdgeMaxFlowProperties::*&gt;, boost::edge_capacity_t, boost::no_property&gt; &gt; &gt;]' sample.cpp:39:152: required from here /usr/local/include/boost/graph/detail/adjacency_list.hpp:2651:29: error: forming reference to void /usr/local/include/boost/graph/detail/adjacency_list.hpp:2652:35: error: forming reference to void /usr/local/include/boost/graph/detail/adjacency_list.hpp:2656:61: error: forming reference to void /usr/local/include/boost/graph/detail/adjacency_list.hpp:2659:68: error: forming reference to void sample.cpp: In function 'int main()': sample.cpp:39:152: error: no matching function for call to 'edmonds_karp_max_flow(Graph&amp;, Node&amp;, Node&amp;, boost::bgl_named_params&lt;boost::vec_adj_list_vertex_property_map&lt;boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;, boost::adjacency_list&lt;boost::listS, boost::vecS, boost::bidirectionalS, NodeMaxFlowProperties, EdgeMaxFlowProperties&gt;*, boost::default_color_type, boost::default_color_type&amp;, boost::default_color_type NodeMaxFlowProperties::*&gt;, boost::vertex_color_t, boost::bgl_named_params&lt;boost::adj_list_edge_property_map&lt;boost::bidirectional_tag, boost::detail::edge_desc_impl&lt;boost::bidirectional_tag, unsigned int&gt;, boost::detail::edge_desc_impl&lt;boost::bidirectional_tag, unsigned int&gt;&amp;, unsigned int, EdgeMaxFlowProperties, boost::detail::edge_desc_impl&lt;boost::bidirectional_tag, unsigned int&gt; EdgeMaxFlowProperties::*&gt;, boost::edge_reverse_t, boost::bgl_named_params&lt;boost::adj_list_edge_property_map&lt;boost::bidirectional_tag, double, double&amp;, unsigned int, EdgeMaxFlowProperties, double EdgeMaxFlowProperties::*&gt;, boost::edge_residual_capacity_t, boost::bgl_named_params&lt;boost::adj_list_edge_property_map&lt;boost::bidirectional_tag, double, double&amp;, unsigned int, EdgeMaxFlowProperties, double EdgeMaxFlowProperties::*&gt;, boost::edge_capacity_t, boost::no_property&gt; &gt; &gt; &gt;)' sample.cpp:39:152: note: candidates are: In file included from tools/examples/tool_config_example/src/tool_config_example.cpp:17:0: /usr/local/include/boost/graph/edmonds_karp_max_flow.hpp:79:3: note: template&lt;class Graph, class CapacityEdgeMap, class ResidualCapacityEdgeMap, class ReverseEdgeMap, class ColorMap, class PredEdgeMap&gt; typename boost::property_traits&lt;CapacityEdgeMap&gt;::value_type boost::edmonds_karp_max_flow(Graph&amp;, typename boost::graph_traits&lt;VertexListGraph&gt;::vertex_descriptor, typename boost::graph_traits&lt;VertexListGraph&gt;::vertex_descriptor, CapacityEdgeMap, ResidualCapacityEdgeMap, ReverseEdgeMap, ColorMap, PredEdgeMap) /usr/local/include/boost/graph/edmonds_karp_max_flow.hpp:79:3: note: template argument deduction/substitution failed: sample.cpp:39:152: note: candidate expects 8 arguments, 4 provided In file included from tools/examples/tool_config_example/src/tool_config_example.cpp:17:0: /usr/local/include/boost/graph/edmonds_karp_max_flow.hpp:223:3: note: template&lt;class Graph, class P, class T, class R&gt; typename boost::detail::edge_capacity_value::type boost::edmonds_karp_max_flow(Graph&amp;, typename boost::graph_traits&lt;IncidenceGraph&gt;::vertex_descriptor, typename boost::graph_traits&lt;IncidenceGraph&gt;::vertex_descriptor, const boost::bgl_named_params&lt;T, Tag, Base&gt;&amp;) /usr/local/include/boost/graph/edmonds_karp_max_flow.hpp:223:3: note: substitution of deduced template arguments resulted in errors seen above /usr/local/include/boost/graph/edmonds_karp_max_flow.hpp:238:3: note: template&lt;class Graph&gt; typename boost::property_traits&lt;typename boost::property_map&lt;Graph, boost::edge_capacity_t&gt;::const_type&gt;::value_type boost::edmonds_karp_max_flow(Graph&amp;, typename boost::graph_traits&lt;Graph&gt;::vertex_descriptor, typename boost::graph_traits&lt;Graph&gt;::vertex_descriptor) /usr/local/include/boost/graph/edmonds_karp_max_flow.hpp:238:3: note: template argument deduction/substitution failed: sample.cpp:39:152: note: candidate expects 3 arguments, 4 provided </pre><p> Do you think that it's the same problem, or should I report it to a different bug/ticket? </p> <p> Thanks! </p> <p> Albert </p> </description> <category>Ticket</category> </item> <item> <author>Albert Gil <albert.gil@…></author> <pubDate>Mon, 13 Oct 2014 07:58:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8791#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8791#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8791#comment:2" title="Comment 2">Albert Gil &lt;albert.gil@…&gt;</a>: </p> <blockquote class="citation"> <p> I've a very similar problem with <code>boost/graph/dijkstra_shortest_paths.hpp</code>, it should be included before <code>boost/graph/strong_components.hpp</code>... could it be related also to this ADL problem? Also I've a very similar problem with <code>boost/graph/edmonds_karp_max_flow.hpp</code>, but I can't make it compile at all (changing headers order) on 1.55, it works on 1.50. </p> </blockquote> <p> Sorry, I've just enabled <code>-std=c++11</code> in gcc and it just worked! </p> </description> <category>Ticket</category> </item> <item> <author>mael.valais@…</author> <pubDate>Wed, 03 Jun 2015 14:39:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8791#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8791#comment:4</guid> <description> <p> I just tested your code with: </p> <ul><li><code>g++-4.8.4</code> with <code>-std=c++11</code> and <code>boost 1.50.0</code> -&gt; <strong>OK</strong> </li><li><code>g++-4.8.4</code> with <code>-std=c++11</code> and <code>boost 1.55.0</code> -&gt; <strong>NOK</strong> </li><li><code>g++-4.8.4</code> with <code>-std=c++11</code> and <code>boost 1.58.0</code> -&gt; <strong>NOK</strong> </li></ul><p> What happend, did the "max-flow capacity property" break from <code>1.50.0</code> to <code>1.55.0</code>? (see in <code>boost/graph/named_function_params.hpp:326</code> for <code>boost 1.58.0</code>) </p> </description> <category>Ticket</category> </item> <item> <author>albert.gil@…</author> <pubDate>Wed, 03 Jun 2015 15:25:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8791#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8791#comment:5</guid> <description> <p> Sorry, you are right: the <code>-std=c++11</code> didn't solved the problem at all! It was a false-positive... I missed to report it here. </p> <p> My final workaround (after trying my best) was to not calling the main/public <code>edmonds_karp_max_flow</code> function: </p> <pre class="wiki">float64 flow = boost::edmonds_karp_max_flow( graph, source, sink, boost::capacity_map ( get(&amp;Graph::EdgePropertiesType::capacity ,graph)). residual_capacity_map( get(&amp;Graph::EdgePropertiesType::residual_capacity,graph)). reverse_edge_map ( get(&amp;Graph::EdgePropertiesType::reverse_edge ,graph)). color_map ( get(&amp;Graph::NodePropertiesType::color ,graph))); </pre><p> But calling the "internal" funtion with more parameters: </p> <pre class="wiki">float64 flow = boost::edmonds_karp_max_flow( graph, source, sink, get(&amp;Graph::EdgePropertiesType::capacity, graph), get(&amp;Graph::EdgePropertiesType::residual_capacity, graph), get(&amp;Graph::EdgePropertiesType::reverse_edge, graph), get(&amp;Graph::NodePropertiesType::color, graph), get(&amp;Graph::NodePropertiesType::predecessor, graph)); </pre><p> Not sure why, but it worked...? </p> <p> Albert </p> </description> <category>Ticket</category> </item> <item> <author>edaskel@…</author> <pubDate>Wed, 03 Jun 2015 23:06:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8791#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8791#comment:6</guid> <description> <p> Appears to be svn commit 77549, but I'm not sure why. </p> </description> <category>Ticket</category> </item> <item> <author>edaskel@…</author> <pubDate>Thu, 04 Jun 2015 04:44:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8791#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8791#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8791#comment:6" title="Comment 6">edaskel@…</a>: </p> <blockquote class="citation"> <p> Appears to be svn commit 77549, but I'm not sure why. </p> </blockquote> <p> I believe it is because named_function_params.hpp, line 326, has the arguments to get_param_type in reverse order. The Tag should be provided first. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 04 Jun 2015 07:59:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8791#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8791#comment:8</guid> <description> <p> @albert Thank you for your answer. <code>-std=c++11</code> is no help then :( </p> <p> @edaskel You found it! Thank you so much!!! I just tried to invert them, and it worked. </p> <p> Before in <code>boost/graph/named_function_params.hpp:326</code>: </p> <pre class="wiki">typedef typename detail::choose_impl_result&lt;boost::mpl::true_, Graph, typename get_param_type&lt;Params, edge_capacity_t&gt;::type, edge_capacity_t&gt;::type CapacityEdgeMap; </pre><p> After in <code>boost/graph/named_function_params.hpp:326</code>: </p> <pre class="wiki">typedef typename detail::choose_impl_result&lt;boost::mpl::true_, Graph, typename get_param_type&lt;edge_capacity_t, Params&gt;::type, edge_capacity_t&gt;::type CapacityEdgeMap; </pre><p> Shouldn't we submit that fix to the trunk? </p> </description> <category>Ticket</category> </item> <item> <author>Maël Valais <mael.valais@…></author> <pubDate>Thu, 04 Jun 2015 12:30:34 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/8791 https://svn.boost.org/trac10/ticket/8791 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">0001-trac-8791-reversed-order-of-get_param_type-parameter.patch</span> </li> </ul> Ticket edaskel@… Thu, 04 Jun 2015 14:37:28 GMT <link>https://svn.boost.org/trac10/ticket/8791#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8791#comment:9</guid> <description> <p> Maël we should also make a new bug, as this one was marked "fixed" 2 years ago and actually is not related to your issue after all :) -Jeff </p> </description> <category>Ticket</category> </item> </channel> </rss>