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

Compilation failure in clang/LLVM 19 due to incorrect member name base() in graph_traits_HalfedgeDS.h #8313

Closed
tylermorganwall opened this issue Jun 27, 2024 · 3 comments
Labels
Bug Patch Provided Issue with a proposed patch Pkg::BGL

Comments

@tylermorganwall
Copy link
Contributor

tylermorganwall commented Jun 27, 2024

Issue Details

I write an R package that links CGAL, and I was recently informed that the package was failing to install with LLVM 19 due to missing member functions.

Here are the installation logs:

/data/gannet/ripley/R/test-clang/RcppCGAL/include/CGAL/boost/graph/iterator.h:219:22: error: no member named 'base' in 'Halfedge_around_source_iterator'
219 | return (! (this->base() == nullptr));
| ~~~~ ^
/data/gannet/ripley/R/test-clang/RcppCGAL/include/CGAL/boost/graph/iterator.h:313:22: error: no member named 'base' in 'Halfedge_around_target_iterator'
313 | return (! (this->base() == nullptr));
| ~~~~ ^
/data/gannet/ripley/R/test-clang/RcppCGAL/include/CGAL/boost/graph/iterator.h:405:22: error: no member named 'base' in 'Halfedge_around_face_iterator'
405 | return (! (this->base() == nullptr));
| ~~~~ ^
3 errors generated.

(Here are the full logs: https://www.stats.ox.ac.uk/pub/bdr/clang19/raybevel.log)

I believe this should be this::base_reference(), as all the other similarly templated classes in the header call that member function.

Example:

Halfedge_around_source_circulator()
{}
Halfedge_around_source_circulator(halfedge_descriptor hd, const Graph& g)
: Halfedge_around_source_circulator::iterator_adaptor_(Halfedge_around_target_circulator<Graph>(opposite(hd,g),g)), opp(g)
{}
Halfedge_around_source_circulator(vertex_descriptor vd, const Graph& g)
: Halfedge_around_source_circulator::iterator_adaptor_(Halfedge_around_target_circulator<Graph>(halfedge(vd,g),g)), opp(g)
{}
explicit operator bool() const
{
return (! (this->base_reference() == nullptr));
}

Source Code

The lines causing these errors is located in these locations:

#ifndef DOXYGEN_RUNNING
explicit operator bool() const
{
return (! (this->base() == nullptr));

explicit operator bool() const
{
return (! (this->base() == nullptr));
}

explicit operator bool() const
{
return (! (this->base() == nullptr));
}

Environment

  • Clang/LLVM 19.0.0
@lrineau
Copy link
Member

lrineau commented Jun 28, 2024

Hi, those operator bool should be removed: they are useless, because the types are iterators, and not circulators.

I suggest the following patch:

diff --git a/BGL/include/CGAL/boost/graph/iterator.h b/BGL/include/CGAL/boost/graph/iterator.h
index 54b54c08ecb..cef4a913cad 100644
--- a/BGL/include/CGAL/boost/graph/iterator.h
+++ b/BGL/include/CGAL/boost/graph/iterator.h
@@ -214,11 +214,6 @@ public:
 
 #ifndef DOXYGEN_RUNNING
 
-  explicit operator bool() const
-  {
-    return (! (this->base() == nullptr));
-  }
-
   bool operator==( const Self& i) const {
     CGAL_assertion( anchor == anchor);
     return  ( g == i.g) && ( pos == i.pos) && ( winding == i.winding);
@@ -308,11 +303,6 @@ public:
 
 #ifndef DOXYGEN_RUNNING
 
-  explicit operator bool() const
-  {
-    return (! (this->base() == nullptr));
-  }
-
   bool operator==( const Self& i) const {
     CGAL_assertion( anchor == anchor);
     return  ( g == i.g) && ( pos == i.pos) && ( winding == i.winding);
@@ -400,11 +390,6 @@ public:
   pointer           operator -> ( )       { return &pos; }
   const value_type* operator -> ( ) const { return &pos; }
 
-  explicit operator bool() const
-  {
-    return (! (this->base() == nullptr));
-  }
-
   bool operator==( const Self& i) const {
     CGAL_assertion( anchor == anchor);
     return  ( g == i.g) && ( pos == i.pos) && ( winding == i.winding);

Can you please try it, and let us know?

@lrineau lrineau added Bug Pkg::BGL Patch Provided Issue with a proposed patch labels Jun 28, 2024
@tylermorganwall
Copy link
Contributor Author

I have confirmed the above patch fixes the issue on clang/LLVM 19.0.0.

@tylermorganwall
Copy link
Contributor Author

Here is the Dockerfile I used to confirm the patch works:

# Use an Ubuntu base image
FROM ubuntu:22.04

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary packages
RUN apt-get update && apt-get install -y \
    build-essential \
    cmake \
    git \
    wget \
    lsb-release \
    software-properties-common \
    gnupg \
    libgmp-dev \
    libmpfr-dev \
    libboost-all-dev \
    libeigen3-dev \
    patch

# Install clang/LLVM 19.0.0
RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 19

# Set clang/LLVM as default compiler
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang-19 100
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-19 100

# Copy the patch file into the container
COPY cgal_patch.diff /usr/local/src/cgal_patch.diff

# Clone and build CGAL with the patch
RUN git clone https://github.com/CGAL/cgal.git /usr/local/src/cgal && \
    cd /usr/local/src/cgal && \
    git apply /usr/local/src/cgal_patch.diff && \
    mkdir -p build && cd build && \
    cmake -DCMAKE_BUILD_TYPE=Release .. && \
    make && \
    make install && \
    echo "CGAL build and installation completed successfully."

# Verify installation
RUN ls /usr/local/lib && ls /usr/local/include/CGAL

# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Set up a working directory
WORKDIR /workspace

# Command to keep the container running
CMD ["bash"]

And the test file I compiled:

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <iostream>

int main() {
    typedef CGAL::Simple_cartesian<double> Kernel;
    typedef CGAL::Surface_mesh<Kernel::Point_3> Mesh;

    Mesh mesh;
    std::cout << "CGAL and clang/LLVM 19.0.0 are set up correctly!" << std::endl;
    return 0;
}

Without the patch, the compilation with clang 19 failed with the error in the initial post. With the patch applied there is no error and the program successfully compiles.

tylermorganwall added a commit to tylermorganwall/cgal that referenced this issue Jul 3, 2024
Confirmed fix to compilation issue in clang//llvm 19 (CGAL#8313)
lrineau pushed a commit to tylermorganwall/cgal that referenced this issue Jul 16, 2024
Confirmed fix to compilation issue in clang//llvm 19 (CGAL#8313)
lrineau added a commit to lrineau/cgal that referenced this issue Jul 17, 2024
Confirmed fix to compilation issue in clang//llvm 19 (CGAL#8313)
@lrineau lrineau added Tested and removed Tested labels Jul 17, 2024
sloriot added a commit that referenced this issue Jul 23, 2024
…ssue-8313

Fix clang/llvm 19 compilation issue in iterator.h (issue #8313)
@sloriot sloriot closed this as completed Jul 23, 2024
mering pushed a commit to intrinsic-3p/cgal that referenced this issue Sep 19, 2024
Confirmed fix to compilation issue in clang//llvm 19 (CGAL#8313)
mering pushed a commit to intrinsic-3p/cgal that referenced this issue Sep 19, 2024
Confirmed fix to compilation issue in clang//llvm 19 (CGAL#8313)
mering pushed a commit to intrinsic-3p/cgal that referenced this issue Sep 19, 2024
Confirmed fix to compilation issue in clang//llvm 19 (CGAL#8313)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Patch Provided Issue with a proposed patch Pkg::BGL
Projects
None yet
Development

No branches or pull requests

3 participants