Skip to content

Commit 6407397

Browse files
paparodeotobiasdiez
authored andcommitted
clang-19 build: workaround narrowing-const-reference error
``` In file included from build/cythonized/sage/graphs/base/boost_graph.cpp:1278: build/cythonized/sage/graphs/base/boost_interface.cpp:119:34: error: non-constant-expression cannot be narrowed from type 'value_type' (aka 'unsigned long') to 'int' in initializer list [-Wc++11-narrowing-const-reference] 119 | to_return.push_back({index[boost::source(*ei, graph)], | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ build/cythonized/sage/graphs/base/boost_graph.cpp:17503:29: note: in instantiation of member function 'BoostGraph<boost::vecS, boost::vecS, boost::directedS, boost::vecS, boost::property<boost::edge_weight_t, double>>::edge_list' requested here 17503 | __pyx_v_edges = __pyx_v_g.edge_list(); ^ ``` https://clang.llvm.org/docs/DiagnosticsReference.html#wc-11-narrowing-const-reference To silence the error assign to a v_index outside of the initializer list.
1 parent 21d287c commit 6407397

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/sage/graphs/base/boost_interface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class BoostGraph
116116
std::vector<std::pair<v_index, std::pair<v_index, double>>> to_return;
117117
typename boost::graph_traits<adjacency_list>::edge_iterator ei, ei_end;
118118
for (boost::tie(ei, ei_end) = boost::edges(graph); ei != ei_end; ++ei) {
119-
to_return.push_back({index[boost::source(*ei, graph)],
119+
v_index sidx = index[boost::source(*ei, graph)];
120+
to_return.push_back({sidx,
120121
{index[boost::target(*ei, graph)],
121122
get(boost::edge_weight, graph, *ei)}});
122123
}

0 commit comments

Comments
 (0)