eigen - 来自 Eigen 的 2000 行警告

标签 eigen compiler-warnings rcppeigen

我正在使用 g++ 8.5.0 和 Eigen 库 v-3.3.9。构建利用 Eigen 的应用程序时,编译器会生成 about 2000 lines of warnings 。下面仅显示了其中的一小部分。

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;
                                                                       

这些警告根本不影响执行。

如何在不更改编译器命令的情况下最好地禁用这些警告?

谢谢!

最佳答案

Eigen 使用的相当奇特的优化加上其作为纯模板库的性质以及对各种编译器的支持意味着它的代码默认情况下会发出大量编译器警告。为了防止这种情况,它包含一个 header src/Core/util/DisableStupidWarnings.h使用特定于编译器的编译指示只是为了停用这些警告。

由于某种原因,RcppEigen将这些编译指示注释掉。如果我明白this particular bug report正确的是,它是 CRAN Repository Policy这样做。

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

关于eigen - 来自 Eigen 的 2000 行警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76411874/

相关文章:

objective-c - 强制子类在 Objective-C 中调用其父类(super class)方法

c++ - GCC 警告字段未初始化使用

c++ - 使用 R 和 Rcpp,如何将两个稀疏 Matrix::csr/csc 格式的矩阵相乘?

c++ - 在Eigen 2库中使用linearRegression时模板自变量推导/替换失败

c++ - 将 pcl::PointCloud 转换为 Eigen::MatrixBase

c++ - Eigen sum() float

c++ - 特征:如何用一些子稀疏矩阵初始化稀疏矩阵

objective-c - -Wunused-value 警告的奇怪行为