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

            Bug ID: 102043
           Summary: Wrong array types used for negative stride accesses
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

gfortran.dg/vector_subscript_1.f90 fails with -O -fipa-pta because

When the frontend lowers idx (10:6:-2) it generates

      parm.22D.4083.dimD.4082[0].lboundD.3942 = 1;
      parm.22D.4083.dimD.4082[0].uboundD.3943 = 3;
      parm.22D.4083.dimD.4082[0].strideD.3941 = -2;
      parm.22D.4083.dataD.4078 = (voidD.27 *) &idxD.4029[9];
...
              D.4091 = (*(integer(kind=4)D.8[0:] *)
parm.22D.4083.dataD.4078)[parm.22D.4083.dimD.4082[0].strideD.3941 *
NON_LVALUE_EXPR <S.24D.4090>];

and that looks clearly wrong to me, we have an access to an array [0:] but
with negative index.  The middle-end here correctly concludes that this access
can only possibly access idx[9] and not any other element.

Reply via email to