Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeshBoolean: fix GCC 14 compile error #4499

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FliegendeWurst
Copy link

Otherwise the build fails with:

/build/source/src/libslic3r/MeshBoolean.cpp:161:16: error: non-const lvalue reference to type 'reference' (aka 'CGAL::SM_Vertex_index') cannot bind to a temporary of type 'reference' (aka 'CGAL::SM_Vertex_index')
  161 |     for (auto &vi : cgalmesh.vertices()) {
      |                ^  ~
/build/source/src/libslic3r/MeshBoolean.cpp:188:12: note: in instantiation of function template specialization 'Slic3r::MeshBoolean::cgal::cgal_to_triangle_mesh<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick>>>' requested here
  188 |     return cgal_to_triangle_mesh(cgalmesh.m);
      |            ^
/nix/store/qg5xvm9icynvn84inj4g0z6zq9ibl06b-cgal-5.6.2/include/CGAL/Iterator_range.h:49:5: note: selected 'begin' function with iterator type 'CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick>>::Index_iterator<CGAL::SM_Vertex_index>'
   49 |   I begin() const
      |     ^
/build/source/src/libslic3r/MeshBoolean.cpp:166:16: error: non-const lvalue reference to type 'reference' (aka 'CGAL::SM_Face_index') cannot bind to a temporary of type 'reference' (aka 'CGAL::SM_Face_index')
  166 |     for (auto &face : cgalmesh.faces()) {
      |                ^    ~
/nix/store/qg5xvm9icynvn84inj4g0z6zq9ibl06b-cgal-5.6.2/include/CGAL/Iterator_range.h:49:5: note: selected 'begin' function with iterator type 'CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick>>::Index_iterator<CGAL::SM_Face_index>'
   49 |   I begin() const
      |     ^
3 warnings and 2 errors generated.

@@ -147,12 +147,12 @@ template<class _Mesh> TriangleMesh cgal_to_triangle_mesh(const _Mesh &cgalmesh)
const auto &vertices = cgalmesh.vertices();
int vsize = int(vertices.size());

for (auto &vi : vertices) {
for (auto vi : vertices) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't a const reference, i.e. adding const, enough on both list traversals (to avoid value copy)?

At least that is what Gentoo Linux applies as compile patch since considerable time, see
https://gitweb.gentoo.org/repo/gentoo.git/tree/media-gfx/superslicer/files/superslicer-2.5.59.8-fix-compilation-error-gnu17.patch

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That also works, I suppose. In that case I would suggest to apply the Gentoo patch instead of this PR.

@FliegendeWurst FliegendeWurst marked this pull request as draft January 18, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants