https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247

            Bug ID: 106247
           Summary: GCC12 warning in Eigen: array subscript is partly
                    outside array bounds
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

If one compiles the following program using Eigen 3.4.0:

#include <Eigen/Dense>

int main(){
    Eigen::Array<double, 2, 2> a;
    a.setRandom();
    Eigen::Array<double, 3, 2> b;
    b.col(0).tail(2) = a.col(1);
}


in GCC12 with command-line options: -std=c++20 -Wall -Wextra -pedantic-errors
-O2 -march=haswell
then a large error occurs ending with

/opt/compiler-explorer/gcc-12.1.0/lib/gcc/x86_64-linux-gnu/12.1.0/include/avxintrin.h:893:24:
warning: array subscript '__m256d_u[0]' is partly outside array bounds of
'Eigen::Array<double, 2, 2> [1]' [-Warray-bounds]
  893 |   return *(__m256d_u *)__P;
      |                        ^~~

Similar errors occur with other -march options or other code using Eigen
library.

Everything is fine in GCC 11 or other compilers. Online demo:
https://gcc.godbolt.org/z/hT348GYo9

Is it Eigen or GCC bug? Related discussion:
https://stackoverflow.com/q/72871100/7325599

Reply via email to