Eigen Tensor potential array out of Bounds
### Summary Getting a warning about arrays out of bounds during compilation ### Environment - **Operating System** : Linux - **Architecture** : x64 - **Eigen Version** : 5.0.0 - **Compiler Version** : gcc-13.3.1 - **Compile Flags** : -O3, using C++20 ### Minimal Example ``` g++ -std=c++20 -fmax-errors=4 -O3 -Werror -Wall -Wdisabled-optimization -Winit-self -Wmissing-include-dirs -Woverloaded-virtual -Wno-unused -Wsign-compare -Wformat-security -Wswitch-default -Wformat=2 -Wcast-qual -Wsign-conversion -Wcast-align -Wdouble-promotion -Wsign-promo -Wshadow -Wfloat-equal -pedantic -pedantic-errors -Wundef -Wzero-as-null-pointer-constant -Wredundant-decls -Wsuggest-override -Wextra-semi -Wlogical-op -Wnoexcept -Wstrict-null-sentinel -Wimplicit-fallthrough=5 -Wduplicated-branches -Wformat-overflow -Wformat-signedness -Wsuggest-final-types -Wsuggest-final-methods -Wno-unknown-pragmas In member function ‘constexpr std::array<_Tp, _Nm>::value_type& std::array<_Tp, _Nm>::operator[](size_type) [with _Tp = long int; long unsigned int _Nm = 1]’, inlined from ‘Eigen::TensorContractionEvaluatorBase<Derived>::TensorContractionEvaluatorBase(const XprType&, const Device&) [with Derived = Eigen::TensorEvaluator<const Eigen::TensorContractionOp<const std::array<Eigen::IndexPair<long unsigned int>, 1>, const Eigen::TensorMap<const Eigen::Tensor<double, 2, 0, long int>, 0, Eigen::MakePointer>, const Eigen::TensorMap<const Eigen::Tensor<double, 3, 0, long int>, 0, Eigen::MakePointer>, const Eigen::NoOpOutputKernel>, Eigen::DefaultDevice>]’ at .../include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContraction.h:495:56, inlined from ‘Eigen::TensorEvaluator<const Eigen::TensorContractionOp<Dimensions, LhsXprType, RhsXprType, OutputKernelType>, Device_>::TensorEvaluator(const XprType&, const Device&) [with Indices = const std::array<Eigen::IndexPair<long unsigned int>, 1>; LeftArgType = const Eigen::TensorMap<const Eigen::Tensor<double, 2, 0, long int>, 0, Eigen::MakePointer>; RightArgType = const Eigen::TensorMap<const Eigen::Tensor<double, 3, 0, long int>, 0, Eigen::MakePointer>; OutputKernelType = const Eigen::NoOpOutputKernel; Device = Eigen::DefaultDevice]’ at .../include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContraction.h:948:77, inlined from ‘Eigen::TensorEvaluator<const Eigen::TensorAssignOp<LhsXprType, RhsXprType>, Device>::TensorEvaluator(const XprType&, const Device&) [with LeftArgType = Eigen::TensorMap<Eigen::Tensor<double, 3, 0, long int>, 0, Eigen::MakePointer>; RightArgType = const Eigen::TensorContractionOp<const std::array<Eigen::IndexPair<long unsigned int>, 1>, const Eigen::TensorMap<const Eigen::Tensor<double, 2, 0, long int>, 0, Eigen::MakePointer>, const Eigen::TensorMap<const Eigen::Tensor<double, 3, 0, long int>, 0, Eigen::MakePointer>, const Eigen::NoOpOutputKernel>; Device = Eigen::DefaultDevice]’ at .../include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h:118:49, inlined from ‘static void Eigen::internal::TensorExecutor<Expression, Eigen::DefaultDevice, true, Eigen::internal::Off>::run(const Expression&, const Eigen::DefaultDevice&) [with Expression = const Eigen::TensorAssignOp<Eigen::TensorMap<Eigen::Tensor<double, 3, 0, long int>, 0, Eigen::MakePointer>, const Eigen::TensorContractionOp<const std::array<Eigen::IndexPair<long unsigned int>, 1>, const Eigen::TensorMap<const Eigen::Tensor<double, 2, 0, long int>, 0, Eigen::MakePointer>, const Eigen::TensorMap<const Eigen::Tensor<double, 3, 0, long int>, 0, Eigen::MakePointer>, const Eigen::NoOpOutputKernel> >]’ at .../include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h:120:48, inlined from ‘Derived& Eigen::TensorBase<Derived, AccessLevel>::operator=(const OtherDerived&) [with OtherDerived = Eigen::TensorContractionOp<const std::array<Eigen::IndexPair<long unsigned int>, 1>, const Eigen::TensorMap<const Eigen::Tensor<double, 2, 0, long int>, 0, Eigen::MakePointer>, const Eigen::TensorMap<const Eigen::Tensor<double, 3, 0, long int>, 0, Eigen::MakePointer>, const Eigen::NoOpOutputKernel>; Derived = Eigen::TensorMap<Eigen::Tensor<double, 3, 0, long int>, 0, Eigen::MakePointer>; int AccessLevel = 1]’ at .../include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h:1237:65, /collab/usr/global/tools/tce4/packages/gcc/gcc-13.3.1/include/c++/13/array:203:24: error: array subscript 9223372036854775808 is above array bounds of ‘std::__array_traits<long int, 1>::_Type’ {aka ‘long int [1]’} [-Werror=array-bounds=] 203 | return _M_elems[__n]; | ~~~~~~~~^ ``` ### Steps to reproduce the issue I can make a reproducer if requested ### What is the current *bug* behavior? ### What is the expected *correct* behavior? ### Relevant logs ### [Optional] Benchmark scripts and results ### Anything else that might help
issue