arithmetic between different enumeration types deprecated in c++20, with Eigen 3.4-rc1
Summary
When computing lpNorm compiled with c++20, the deprecation warning of [-Wdeprecated-anon-enum-enum-conversion] is emitted.
Environment
- Operating System : macOS
- Architecture : x86_64-apple-darwin20.3.0
- Eigen Version : 3.4-rc1
- Compiler Version : Apple clang version 12.0.0 (clang-1200.0.32.29)
- Compile Flags : cmake-debug with -march=native
- Vector Extension : AVX2 (I guess? It shouldn't matter)
Minimal Example
Eigen::MatrixXd matrix = Eigen::MatrixXd::Random(100, 100);
std::cout << matrix.lpNorm<2>() << std::endl;
Steps to reproduce
- set cmake to c++20
- build
What is the current bug behavior?
compile warning
What is the expected correct behavior?
obviously, no warning
Relevant logs
Warning Messages
====================[ Build | Eigen34Test | Debug ]=============================
"/Users/anonymous/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/211.7142.21/CLion.app/Contents/bin/cmake/mac/bin/cmake" --build /Users/anonymous/CLionProjects/Eigen34Test/cmake-build-debug --target Eigen34Test -- -j 12
Scanning dependencies of target Eigen34Test
Building CXX object CMakeFiles/Eigen34Test.dir/main.cpp.o
In file included from /Users/anonymous/CLionProjects/Eigen34Test/main.cpp:2:
In file included from /Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/Core:277:
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/CoreEvaluators.h:564:55: warning: arithmetic between different enumeration types ('Eigen::internal::evaluator<Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > >::(anonymous enum at /Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/CoreEvaluators.h:170:3)' and 'Eigen::internal::functor_traits<Eigen::internal::scalar_abs2_op<double> >::(anonymous enum at /Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/functors/UnaryFunctors.h:102:3)') is deprecated [-Wdeprecated-anon-enum-enum-conversion]
CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/CoreEvaluators.h:90:27: note: in instantiation of template class 'Eigen::internal::unary_evaluator<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> >, Eigen::internal::IndexBased, double>' requested here
struct evaluator : public unary_evaluator<T>
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Redux.h:357:32: note: in instantiation of template class 'Eigen::internal::evaluator<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> > >' requested here
class redux_evaluator : public internal::evaluator<_XprType>
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Redux.h:414:17: note: in instantiation of template class 'Eigen::internal::redux_evaluator<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> > >' requested here
ThisEvaluator thisEval(derived());
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Redux.h:463:20: note: in instantiation of function template specialization 'Eigen::DenseBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> > >::redux<Eigen::internal::scalar_sum_op<double, double> >' requested here
return derived().redux(Eigen::internal::scalar_sum_op<Scalar,Scalar>());
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Dot.h:98:43: note: in instantiation of member function 'Eigen::DenseBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> > >::sum' requested here
return numext::real((*this).cwiseAbs2().sum());
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Dot.h:110:23: note: in instantiation of member function 'Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::squaredNorm' requested here
return numext::sqrt(squaredNorm());
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Dot.h:231:14: note: in instantiation of member function 'Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::norm' requested here
return m.norm();
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Dot.h:269:49: note: in instantiation of member function 'Eigen::internal::lpNorm_selector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::run' requested here
return internal::lpNorm_selector<Derived, p>::run(*this);
^
/Users/anonymous/CLionProjects/Eigen34Test/main.cpp:25:25: note: in instantiation of function template specialization 'Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::lpNorm<2>' requested here
std::cout << matrix.lpNorm<2>() << std::endl;
^
In file included from /Users/anonymous/CLionProjects/Eigen34Test/main.cpp:2:
In file included from /Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/Core:317:
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Redux.h:61:41: warning: arithmetic between different enumeration types ('Eigen::internal::redux_evaluator<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> > >::(anonymous enum at /Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Redux.h:369:3)' and 'Eigen::internal::unary_evaluator<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> >, Eigen::internal::IndexBased, double>::(anonymous enum at /Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/CoreEvaluators.h:563:3)') is deprecated [-Wdeprecated-anon-enum-enum-conversion]
: Evaluator::SizeAtCompileTime * Evaluator::CoeffReadCost + (Evaluator::SizeAtCompileTime-1) * functor_traits<Func>::Cost,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Redux.h:186:26: note: in instantiation of template class 'Eigen::internal::redux_traits<Eigen::internal::scalar_sum_op<double, double>, Eigen::internal::redux_evaluator<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> > > >' requested here
int Traversal = redux_traits<Func, Evaluator>::Traversal,
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Redux.h:418:20: note: in instantiation of default argument for 'redux_impl<Eigen::internal::scalar_sum_op<double, double>, Eigen::internal::redux_evaluator<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> > > >' required here
return internal::redux_impl<Func, ThisEvaluator>::run(thisEval, func, derived());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Redux.h:463:20: note: in instantiation of function template specialization 'Eigen::DenseBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> > >::redux<Eigen::internal::scalar_sum_op<double, double> >' requested here
return derived().redux(Eigen::internal::scalar_sum_op<Scalar,Scalar>());
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Dot.h:98:43: note: in instantiation of member function 'Eigen::DenseBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs2_op<double>, const Eigen::Matrix<double, -1, -1, 0, -1, -1> > >::sum' requested here
return numext::real((*this).cwiseAbs2().sum());
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Dot.h:110:23: note: in instantiation of member function 'Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::squaredNorm' requested here
return numext::sqrt(squaredNorm());
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Dot.h:231:14: note: in instantiation of member function 'Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::norm' requested here
return m.norm();
^
/Users/anonymous/CLionProjects/Eigen34Test/eigen-3.4-rc1/Eigen/src/Core/Dot.h:269:49: note: in instantiation of member function 'Eigen::internal::lpNorm_selector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::run' requested here
return internal::lpNorm_selector<Derived, p>::run(*this);
^
/Users/anonymous/CLionProjects/Eigen34Test/main.cpp:25:25: note: in instantiation of function template specialization 'Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::lpNorm<2>' requested here
std::cout << matrix.lpNorm<2>() << std::endl;
^
2 warnings generated.
Linking CXX executable Eigen34Test
Built target Eigen34Test
Build finished
Anything else that might help
Only 3.4-rc1 AND c++20 emits this warning; changing to 3.3.9 OR c++17 has no such warning.