Search code examples
c++compiler-warningseigeneigen3

Eigen 3.3 has many warnings with mingw-w64 (GCC 7.1.0)


after the update from mingw-w64 GCC 6.2 to GCC 7.1 (to be precise, migw-w64 version x86_64-7.1.0-posix-sjlj-rt_v5-rev0), the compiler gives a huge amount of warnings. e.g.:

In file included from C:\...\Eigen3_3_3/Eigen/Eigenvalues:45:0,
                 from C:\...\Eigen3_3_3/Eigen/Dense:7,
                 from ..\src\testProject.cpp:5:
C:\...\Eigen3_3_3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h:292:14: warning: optimization attribute on 'int abs(int)' follows definition but the attribute doesn't match [-Wattributes]
   using std::abs;
              ^~~
In file included from C:/.../mingw-w64/x86_64-7.1.0-posix-sjlj-rt_v5-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/cmath:47:0,
                 from C:/.../mingw-w64/x86_64-7.1.0-posix-sjlj-rt_v5-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/complex:44,
                 from C:\...\Eigen\Eigen3_3_3/Eigen/Core:80,
                 from C:\...\Eigen\Eigen3_3_3/Eigen/Dense:1,
                 from ..\src\testProject.cpp:5:
C:/.../mingw-w64/x86_64-7.1.0-posix-sjlj-rt_v5-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/bits/std_abs.h:84:3: note: previous definition of 'constexpr __int128 std::abs(__int128)' was here
   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
   ^~~

Is this a problem with the compiler or should I report a bug to the Eigen developpers?


Solution

  • This is due to a bug in gcc-7: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325

    I just pushed workarounds (i.e., masking the warning): http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1724 (will be part of Eigen 3.3.8).

    If you can't upgrade to the 3.3 version from the repository (or the default branch), or wait for 3.3.8, you can add -Wno-attributes to your compilation flags.