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

--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Thomas Koenig from comment #6)

After looking at the tree dump and some debugging, it is clear that
the error happens on the callee side.

If the callee has a type as dummy argument, it has

    integer(kind=8) D.4820;

    D.4820 = x->dim[0].stride;
    stride.1 = D.4820 != 0 ? D.4820 : 1;
    x.0 = (struct matrix[0:D.4821] * restrict) x->data;
    ubound.0 = (x->dim[0].ubound - x->dim[0].lbound) + 1;
    size.3 = stride.1 * NON_LVALUE_EXPR <ubound.0>;
    offset.2 = -NON_LVALUE_EXPR <stride.1>;
    D.4821 = size.3 + -1;
    D.4822 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <size.3> * 32;
    D.4823 = (sizetype) NON_LVALUE_EXPR <size.3> * 4;
  }
  if (((struct matrix *) x.0 + (sizetype) ((offset.2 + NON_LVALUE_EXPR
<stride.1>) * 4))->nrows != 2)
    {
      _gfortran_error_stop_string (0B, 0, 0);
    }
  L.1:;
}

so the access is calculated with offset.2, which is calculated.

For a class (test case from #6), it is

  {
    integer(kind=8) D.4829;

    D.4829 = x->_data.dim[0].stride;
    stride.1 = D.4829 != 0 ? D.4829 : 1;
    x.0 = (struct matrix[0:D.4830] *) x->_data.data;
    ubound.0 = (x->_data.dim[0].ubound - x->_data.dim[0].lbound) + 1;
    size.3 = stride.1 * NON_LVALUE_EXPR <ubound.0>;
    offset.2 = -NON_LVALUE_EXPR <stride.1>;
    D.4830 = size.3 + -1;
    D.4831 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <size.3> * 32;
    D.4832 = (sizetype) NON_LVALUE_EXPR <size.3> * 4;
  }
  if (((struct matrix *) (x->_data.data + (sizetype) ((x->_data.offset +
NON_LVALUE_EXPR <x->_data.dim[0].stride>) * x->_vptr->_size)))->nrows != 2)
    {
      _gfortran_error_stop_string (0B, 0, 0);
    }
  L.1:;
}

The problem is in the x->_data.offset, that should be offset.2.

Reply via email to