Search code examples
c++gcceigeneigen3msys2

Eigen compilation error with gcc 8.2.1 on MSYS2


We are facing errors compiling against Eigen 3.3.7 (and probably older versions) against the latest versions of GCC 8.2.1 supplied by MSYS2. Strangely, this only happens with the latest builds of the same package (mingw-w64-x86_64-gcc 8.2.1):

  • 8.2.1+20181123-1 : fine
  • 8.2.1+20181130-1 : error
  • 8.2.1+20181207-1 : error

The error is:

In file included from C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/SparseCore:50,
                 from C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/Sparse:26,
                 from C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/Eigen:2,
                 from src/registration/transform/search.h:21,
                 from src/registration/transform/initialiser_helpers.cpp:20:
C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/src/SparseCore/SparseBlock.h: In member function 'Eigen::internal::sparse_matrix_block_impl<SparseMatrixType, BlockRows, BlockCols>::BlockType& Eigen::internal::sparse_matrix_block_impl<SparseMatrixType, BlockRows, BlockCols>::operator=(const BlockType&)':
C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/src/SparseCore/SparseBlock.h:216:33: error: expected primary-expression before '>' token
       return operator=<BlockType>(other);

                             ^

I'm assuming this is a bug in the GCC package supplied by MSYS2, rather than Eigen (the SparseBlock.h file hasn't changed for a while, as far as I can tell). Are the different GCC builds based on the same source code? Any idea what the issue might be?


EDIT: here is a MCVE:

test.cpp:

#include <Eigen/Eigen>
int main () { return 0; }

compile with g++ 8.2.1 (version 8.2.1+20181130-1 or newer - no error with older version):

$ g++ $(pkg-config --cflags eigen3) test.cpp -o test
In file included from C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/SparseCore:50,
                 from C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/Sparse:26,
                 from C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/Eigen:2,
                 from test.cpp:1:
C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/src/SparseCore/SparseBlock.h: In member function 'Eigen::internal::sparse_matrix_block_impl<SparseMatrixType, BlockRows, BlockCols>::BlockType& Eigen::internal::sparse_matrix_block_impl<SparseMatrixType, BlockRows, BlockCols>::operator=(const BlockType&)':
C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/src/SparseCore/SparseBlock.h:216:33: error: expected primary-expression before '>' token
       return operator=<BlockType>(other);
                                 ^

Solution

  • Further investigation suggests this is indeed a GCC bug. I've reported this on GCC Bugzilla, and I'll close this thread. Thanks!