Skip to content
This repository has been archived by the owner on Feb 26, 2025. It is now read-only.

Commit

Permalink
work w/ clang17 (#486)
Browse files Browse the repository at this point in the history
Disable`-Wno-float-equal` after a couple fixes
  • Loading branch information
mgeplf authored Jan 4, 2024
1 parent 6038b3b commit 9c17dfc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
1 change: 0 additions & 1 deletion CMake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(FLAGS "${FLAGS} -Wno-documentation")
set(FLAGS "${FLAGS} -Wno-documentation-unknown-command")

set(FLAGS "${FLAGS} -Wno-float-equal")
set(FLAGS "${FLAGS} -Wno-padded")
set(FLAGS "${FLAGS} -Wno-weak-vtables")
set(FLAGS "${FLAGS} -Wno-covered-switch-default")
Expand Down
13 changes: 10 additions & 3 deletions binds/python/morphio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
#include "bind_mutable.h"
#include "bind_vasculature.h"

#include "bindings_utils.h"


namespace py = pybind11;

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
#endif

PYBIND11_MODULE(_morphio, m) {
bind_enums(m);
bind_misc(m);
Expand All @@ -27,3 +30,7 @@ PYBIND11_MODULE(_morphio, m) {
py::module vasc_module = m.def_submodule("vasculature");
bind_vasculature(vasc_module);
}

#if defined(__clang__)
#pragma clang diagnostic pop
#endif
3 changes: 1 addition & 2 deletions include/morphio/section_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ range<const typename TProperty::Type> SectionBase<T>::get() const {
return {};
}

auto ptr_start = data.data() + range_.first;
return {ptr_start, range_.second - range_.first};
return {&data.at(range_.first), range_.second - range_.first};
}

template <typename T>
Expand Down
3 changes: 2 additions & 1 deletion src/mut/writer_swc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ int writeSoma(std::ofstream& myfile, const std::shared_ptr<morphio::mut::Soma>&

/* Only skip duplicate if it has the same diameter */
bool _skipDuplicate(const std::shared_ptr<morphio::mut::Section>& section) {
return section->diameters().front() == section->parent()->diameters().back();
return std::fabs(section->diameters().front() - section->parent()->diameters().back()) <
morphio::epsilon;
}

void validateSWCSoma(const morphio::mut::Morphology& morph) {
Expand Down
4 changes: 2 additions & 2 deletions src/vasc/section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ range<const typename TProperty::Type> Section::get() const {
if (data.empty()) {
return range<const typename TProperty::Type>();
}
auto ptr_start = data.data() + range_.first;
return range<const typename TProperty::Type>(ptr_start, range_.second - range_.first);
return range<const typename TProperty::Type>(&data.at(range_.first),
range_.second - range_.first);
}

std::vector<Section> Section::predecessors() const {
Expand Down
5 changes: 3 additions & 2 deletions tests/test_point_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
TEST_CASE("morphio::Point") {
using namespace morphio;
Point p{10., 10., 10.};

std::vector<Point> points = {p, p, p};

CHECK(subtract(p, p) == morphio::Point{0, 0, 0});
CHECK(euclidean_distance(p, p) == 0);
REQUIRE_THAT(euclidean_distance(p, p), Catch::WithinAbs(0, 0.001));
CHECK(dumpPoint(p) == "10 10 10");
CHECK(dumpPoints(points) == "10 10 10\n10 10 10\n10 10 10\n");

Expand All @@ -34,7 +35,7 @@ TEST_CASE("morphio::Point") {
auto r = morphio::range<const morphio::Point>();
std::stringstream ss;
ss << r;
CHECK(ss.str() == "");
CHECK(ss.str().empty());

ss.clear();

Expand Down
2 changes: 1 addition & 1 deletion tests/test_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ TEST_CASE("morphio::shared_utils") {
const std::vector<Point> points = {{0, 0, 0}};
const std::vector<floatType> diameters = {1};
CHECK(centerOfGravity(points) == points[0]);
CHECK(maxDistanceToCenterOfGravity(points) == 0);
CHECK(maxDistanceToCenterOfGravity(points) == Approx(0));
CHECK(_somaSurface(SOMA_SINGLE_POINT, diameters, points) == Approx(morphio::PI));
CHECK(_somaSurface(SOMA_SINGLE_POINT, diameters, points) == Approx(morphio::PI));
}
Expand Down

0 comments on commit 9c17dfc

Please sign in to comment.