1

I am using g++ 8.5.0 and Eigen library v-3.3.9. When building an application that utilizes Eigen, the compiler generates about 2000 lines of warnings . Below only shows a tiny fraction of them.

g++ -std=gnu++17 -I"/usr/include/R" -DNDEBUG   -I"/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/Rcpp/include" -I"/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include" -I"/code/cpp/tests" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection  -c testLBFGSandPlainGD.cpp -o testLBFGSandPlainGD.o
g++ -std=gnu++17 -shared -L/usr/lib64/R/lib -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o sourceCpp_22.so testLBFGSandPlainGD.o -L/usr/lib64/R/lib -lRIn file included from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/Core:397,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/Dense:1,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/RcppEigenForward.h:30,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/RcppEigen.h:25,
                 from testLBFGSandPlainGD.cpp:2:
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:60:39: warning: ignoring attributes on template argument ‘__m128’ {aka ‘__vector(4) float’} [-Wignored-attributes]
 template<> struct is_arithmetic<__m128>  { enum { value = true }; };
                                       ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:61:40: warning: ignoring attributes on template argument ‘__m128i’ {aka ‘__vector(2) long long int’} [-Wignored-attributes]
 template<> struct is_arithmetic<__m128i> { enum { value = true }; };
                                        ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:62:40: warning: ignoring attributes on template argument ‘__m128d’ {aka ‘__vector(2) double’} [-Wignored-attributes]
 template<> struct is_arithmetic<__m128d> { enum { value = true }; };
                                        ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:161:43: warning: ignoring attributes on template argument ‘Eigen::internal::Packet4f’ {aka ‘__vector(4) float’} [-Wignored-attributes]
 template<> struct unpacket_traits<Packet4f> { typedef float  type; enum {size=4, alignment=Aligned16}; typedef Packet4f half; };
                                           ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:162:43: warning: ignoring attributes on template argument ‘Eigen::internal::Packet2d’ {aka ‘__vector(2) double’} [-Wignored-attributes]
 template<> struct unpacket_traits<Packet2d> { typedef double type; enum {size=2, alignment=Aligned16}; typedef Packet2d half; };
                                           ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:163:43: warning: ignoring attributes on template argument ‘Eigen::internal::Packet4i’ {aka ‘__vector(2) long long int’} [-Wignored-attributes]
 template<> struct unpacket_traits<Packet4i> { typedef int    type; enum {size=4, alignment=Aligned16}; typedef Packet4i half; };
                                           ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:718:35: warning: ignoring attributes on template argument ‘Eigen::internal::Packet4f’ {aka ‘__vector(4) float’} [-Wignored-attributes]
 struct palign_impl<Offset,Packet4f>
                                   ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:741:35: warning: ignoring attributes on template argument ‘Eigen::internal::Packet4i’ {aka ‘__vector(2) long long int’} [-Wignored-attributes]
 struct palign_impl<Offset,Packet4i>
                                   ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:764:35: warning: ignoring attributes on template argument ‘Eigen::internal::Packet2d’ {aka ‘__vector(2) double’} [-Wignored-attributes]
 struct palign_impl<Offset,Packet2d>
                                   ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:778:34: warning: ignoring attributes on template argument ‘Eigen::internal::Packet4f’ {aka ‘__vector(4) float’} [-Wignored-attributes]
 ptranspose(PacketBlock<Packet4f,4>& kernel) {
                                  ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:783:34: warning: ignoring attributes on template argument ‘Eigen::internal::Packet2d’ {aka ‘__vector(2) double’} [-Wignored-attributes]
 ptranspose(PacketBlock<Packet2d,2>& kernel) {
                                  ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:790:34: warning: ignoring attributes on template argument ‘Eigen::internal::Packet4i’ {aka ‘__vector(2) long long int’} [-Wignored-attributes]
 ptranspose(PacketBlock<Packet4i,4>& kernel) {
                                  ^
In file included from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/Core:377,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/Dense:1,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/RcppEigenForward.h:30,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/RcppEigen.h:25,
                 from testLBFGSandPlainGD.cpp:2:
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:15:70: warning: ignoring attributes on template argument ‘Eigen::internal::Packet4f’ {aka ‘__vector(4) float’} [-Wignored-attributes]
   template<> struct conj_helper<PACKET_REAL, PACKET_CPLX, false,false> {                                          \
                                                                      ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:232:1: note: in expansion of macro ‘EIGEN_MAKE_CONJ_HELPER_CPLX_REAL’
 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:22:70: warning: ignoring attributes on template argument ‘Eigen::internal::Packet4f’ {aka ‘__vector(4) float’} [-Wignored-attributes]
   template<> struct conj_helper<PACKET_CPLX, PACKET_REAL, false,false> {                                          \
                                                                      ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:232:1: note: in expansion of macro ‘EIGEN_MAKE_CONJ_HELPER_CPLX_REAL’
 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:15:70: warning: ignoring attributes on template argument ‘Eigen::internal::Packet2d’ {aka ‘__vector(2) double’} [-Wignored-attributes]
   template<> struct conj_helper<PACKET_REAL, PACKET_CPLX, false,false> {                                          \
                                                                      ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:417:1: note: in expansion of macro ‘EIGEN_MAKE_CONJ_HELPER_CPLX_REAL’
 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:22:70: warning: ignoring attributes on template argument ‘Eigen::internal::Packet2d’ {aka ‘__vector(2) double’} [-Wignored-attributes]
   template<> struct conj_helper<PACKET_CPLX, PACKET_REAL, false,false> {                                          \
                                                                      ^
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:417:1: note: in expansion of macro ‘EIGEN_MAKE_CONJ_HELPER_CPLX_REAL’
 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/Core:370,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/Dense:1,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/RcppEigenForward.h:30,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/RcppEigen.h:25,
                 from testLBFGSandPlainGD.cpp:2:
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h: In instantiation of ‘struct Eigen::internal::find_best_packet<float, 4>’:
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/Matrix.h:22:57:   required from ‘struct Eigen::internal::traits<Eigen::Matrix<float, 4, 1> >’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Geometry/Quaternion.h:242:7:   required from ‘struct Eigen::internal::traits<Eigen::Quaternion<float> >’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Geometry/arch/Geometry_SSE.h:24:46:   required from here
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:187:44: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<float>::type’ {aka ‘__vector(4) float’} [-Wignored-attributes]
          bool Stop = Size==Dynamic || (Size%unpacket_traits<PacketType>::size)==0 || is_same<PacketType,typename unpacket_traits<PacketType>::half>::value>
                                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:187:83: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<float>::type’ {aka ‘__vector(4) float’} [-Wignored-attributes]
          bool Stop = Size==Dynamic || (Size%unpacket_traits<PacketType>::size)==0 || is_same<PacketType,typename unpacket_traits<PacketType>::half>::value>
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:187:83: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<float>::type’ {aka ‘__vector(4) float’} [-Wignored-attributes]
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:187:83: warning: ignoring attributes on template argument ‘Eigen::internal::unpacket_traits<__vector(4) float>::half’ {aka ‘__vector(4) float’} [-Wignored-attributes]
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:205:88: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<float>::type’ {aka ‘__vector(4) float’} [-Wignored-attributes]
   typedef typename find_best_packet_helper<Size,typename packet_traits<T>::type>::type type;
                                                                                        ^~~~
In file included from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/Core:439,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/Dense:1,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/RcppEigenForward.h:30,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/RcppEigen.h:25,
                 from testLBFGSandPlainGD.cpp:2:
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h: In instantiation of ‘class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 4, 1>, 0>’:
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:300:7:   required from ‘class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 4, 1>, 1>’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:551:7:   required from ‘class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 4, 1>, 3>’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/DenseBase.h:41:34:   required from ‘class Eigen::DenseBase<Eigen::Matrix<float, 4, 1> >’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/MatrixBase.h:48:34:   required from ‘class Eigen::MatrixBase<Eigen::Matrix<float, 4, 1> >’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/PlainObjectBase.h:98:7:   required from ‘class Eigen::PlainObjectBase<Eigen::Matrix<float, 4, 1> >’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/Matrix.h:178:7:   required from ‘class Eigen::Matrix<float, 4, 1>’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Geometry/Quaternion.h:46:50:   required from ‘class Eigen::QuaternionBase<Eigen::Quaternion<float> >’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Geometry/Quaternion.h:250:7:   required from ‘class Eigen::Quaternion<float>’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Geometry/arch/Geometry_SSE.h:27:3:   required from here
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<float>::type’ {aka ‘__vector(4) float’} [-Wignored-attributes]
                      >::type PacketReturnType;
                              ^~~~~~~~~~~~~~~~
In file included from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/Core:370,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/Dense:1,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/RcppEigenForward.h:30,
                 from /home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/RcppEigen.h:25,
                 from testLBFGSandPlainGD.cpp:2:
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h: In instantiation of ‘struct Eigen::internal::find_best_packet<double, 4>’:
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/Matrix.h:22:57:   required from ‘struct Eigen::internal::traits<Eigen::Matrix<double, 4, 1> >’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Geometry/Quaternion.h:242:7:   required from ‘struct Eigen::internal::traits<Eigen::Quaternion<double> >’
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Geometry/arch/Geometry_SSE.h:88:47:   required from here
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:187:44: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type’ {aka ‘__vector(2) double’} [-Wignored-attributes]
          bool Stop = Size==Dynamic || (Size%unpacket_traits<PacketType>::size)==0 || is_same<PacketType,typename unpacket_traits<PacketType>::half>::value>
                                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:187:83: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type’ {aka ‘__vector(2) double’} [-Wignored-attributes]
          bool Stop = Size==Dynamic || (Size%unpacket_traits<PacketType>::size)==0 || is_same<PacketType,typename unpacket_traits<PacketType>::half>::value>
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:187:83: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type’ {aka ‘__vector(2) double’} [-Wignored-attributes]
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:187:83: warning: ignoring attributes on template argument ‘Eigen::internal::unpacket_traits<__vector(2) double>::half’ {aka ‘__vector(2) double’} [-Wignored-attributes]
/home/xxxxx/R/x86_64-redhat-linux-gnu-library/4.2/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:205:88: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type’ {aka ‘__vector(2) double’} [-Wignored-attributes]
   typedef typename find_best_packet_helper<Size,typename packet_traits<T>::type>::type type;
                                                                       

These warnings do not affect the execution at all.

How can I disable these warnings preferably without changing the compiler commands?

Thank you!

user2961927
  • 1,290
  • 1
  • 14
  • 22
  • When we were learning Cobol, our instructor always said that the first step after getting the error report was to correct the first error only and run it again. He was right 99% of the errors would disappear... – Solar Mike Jun 06 '23 at 06:22
  • 1
    Please check that the Eigen header `src/Core/util/DisableStupidWarnings.h` includes lines like `#if __GNUC__>=6 #pragma GCC diagnostic ignored "-Wignored-attributes"`. If it does, we can start wondering why this does not work – Homer512 Jun 06 '23 at 08:33
  • @Homer512 This solves the problem! Do you know why by default the whole macro section for GCC is commented? And please post your comment as an answer if u'd like and I'll accept it – user2961927 Jun 06 '23 at 15:14
  • Wait, it was commented out? I don't really understand. – Homer512 Jun 06 '23 at 15:17
  • 2
    @Homer512 I just double checked. I have been using RcppEigen https://cran.r-project.org/web/packages/RcppEigen/index.html . That whole section is indeed commented out for GCC but not for other compilers. However, Eigen 3.3.9 from the official website does not have such issue.. – user2961927 Jun 06 '23 at 15:27

1 Answers1

2

The rather peculiar optimizations that Eigen uses plus its nature as a pure template library plus support for a wide range of compilers means that its code would, by default, emit a ton of compiler warnings. To prevent this, it contains a header src/Core/util/DisableStupidWarnings.h with compiler-specific pragmas just for the purpose of deactivating these warnings.

For some reason, RcppEigen comments these pragmas out. If I understand this particular bug report correctly, it is a CRAN Repository Policy to do so.

Packages should not attempt to disable compiler diagnostics, nor to remove other diagnostic information such as symbols in shared objects.

Homer512
  • 9,144
  • 2
  • 8
  • 25