Skip to content

Commit

Permalink
Fix some compilation issues on modern macOS systems (#6709)
Browse files Browse the repository at this point in the history
* Fix various compiler warnings generated by Apple clang 15, and workaround some boost 1.8 bugs

* Fix formatting.
  • Loading branch information
danpat committed Oct 12, 2023
1 parent b437ce5 commit 31e31a6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ add_dependency_defines(-DBOOST_SPIRIT_USE_PHOENIX_V3)
add_dependency_defines(-DBOOST_RESULT_OF_USE_DECLTYPE)
add_dependency_defines(-DBOOST_FILESYSTEM_NO_DEPRECATED)

# Workaround for https://github.com/boostorg/phoenix/issues/111
add_dependency_defines(-DBOOST_PHOENIX_STL_TUPLE_H_)

add_definitions(${OSRM_DEFINES})
include_directories(SYSTEM ${DEPENDENCIES_INCLUDE_DIRS})

Expand Down
6 changes: 4 additions & 2 deletions include/util/coordinate_calculation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ double getLength(iterator_type begin, const iterator_type end, BinaryOperation o
return false;
};
// side-effect find adding up distances
std::adjacent_find(begin, end, functor);
// Ignore return value, we are only interested in the side-effect
[[maybe_unused]] auto _ = std::adjacent_find(begin, end, functor);

return result;
}
Expand All @@ -202,7 +203,8 @@ findClosestDistance(const Coordinate coordinate, const iterator_type begin, cons
return false;
};

std::adjacent_find(begin, end, compute_minimum_distance);
// Ignore return value, we are only interested in the side-effect
[[maybe_unused]] auto _ = std::adjacent_find(begin, end, compute_minimum_distance);
return current_min;
}

Expand Down
31 changes: 17 additions & 14 deletions src/extractor/intersection/coordinate_extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,19 +887,21 @@ CoordinateExtractor::PrepareLengthCache(const std::vector<util::Coordinate> &coo
segment_distances.push_back(0);
// sentinel
// NOLINTNEXTLINE(bugprone-unused-return-value)
std::find_if(std::next(std::begin(coordinates)),
std::end(coordinates),
[last_coordinate = coordinates.front(),
limit,
&segment_distances,
accumulated_distance = 0.](const util::Coordinate current_coordinate) mutable {
const auto distance = util::coordinate_calculation::greatCircleDistance(
last_coordinate, current_coordinate);
accumulated_distance += distance;
last_coordinate = current_coordinate;
segment_distances.push_back(distance);
return accumulated_distance >= limit;
});
// We're only interested in the side effect of the lambda, not the return value
[[maybe_unused]] auto _ = std::find_if(
std::next(std::begin(coordinates)),
std::end(coordinates),
[last_coordinate = coordinates.front(),
limit,
&segment_distances,
accumulated_distance = 0.](const util::Coordinate current_coordinate) mutable {
const auto distance = util::coordinate_calculation::greatCircleDistance(
last_coordinate, current_coordinate);
accumulated_distance += distance;
last_coordinate = current_coordinate;
segment_distances.push_back(distance);
return accumulated_distance >= limit;
});
return segment_distances;
}

Expand Down Expand Up @@ -1090,7 +1092,8 @@ CoordinateExtractor::SampleCoordinates(const std::vector<util::Coordinate> &coor
};

// misuse of adjacent_find. Loop over coordinates, until a total sample length is reached
std::adjacent_find(coordinates.begin(), coordinates.end(), add_samples_until_length_limit);
[[maybe_unused]] auto _ =
std::adjacent_find(coordinates.begin(), coordinates.end(), add_samples_until_length_limit);

return sampled_coordinates;
}
Expand Down
4 changes: 3 additions & 1 deletion src/partitioner/dinic_max_flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ std::size_t DinicMaxFlow::BlockingFlow(FlowEdges &flow,
};

// augment all adjacent edges
std::adjacent_find(path.begin(), path.end(), augment_one);
// We're only interested in the side-effect of the augment_one function, the return
// value is ignored
[[maybe_unused]] auto _ = std::adjacent_find(path.begin(), path.end(), augment_one);
};

const auto augment_all_paths = [&](const NodeID sink_node_id) {
Expand Down
3 changes: 2 additions & 1 deletion src/util/coordinate_calculation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ double findClosestDistance(const std::vector<Coordinate> &lhs, const std::vector
return false;
};
// NOLINTNEXTLINE(bugprone-unused-return-value)
std::find_if(std::begin(lhs), std::end(lhs), compute_minimum_distance_in_rhs);
[[maybe_unused]] auto _ =
std::find_if(std::begin(lhs), std::end(lhs), compute_minimum_distance_in_rhs);
return current_min;
}

Expand Down

0 comments on commit 31e31a6

Please sign in to comment.