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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.5
                 CC|                            |sandra at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Looking at the dump, GCC 11 has:
      _gfortran_shape_4 (&parm.3, D.3966);
while GCC 12 has:
      x[S.3] = (integer(kind=4)) (((unsigned int) a.dim[S.3].ubound - (unsigned
int) a.dim[S.3].lbound) + 1);

* * * *

Probably caused by:

r12-4591-g1af78e731feb93
Author: Sandra Loosemore <san...@codesourcery.com>
Date:   Tue Oct 19 21:11:15 2021 -0700

    Fortran: Fixes and additional tests for shape/ubound/size [PR94070]

    This patch reimplements the SHAPE intrinsic to be inlined similarly to
    LBOUND and UBOUND, instead of as a library call, to avoid an
    unnecessary array copy.  Various bugs are also fixed.

    gcc/fortran/
            PR fortran/94070

* * *

SHAPE has:
"Result Value. The result has a value whose i-th element is equal to the extent
of dimension i of SOURCE, except that if SOURCE is assumed-rank, and associated
with an assumed-size array, the last element is equal to −1."

Thus, an example for the latter:

GCC 11.4 - good:
           0           2          -1
GCC 12 (to trunk) - wrong:
          -3           2          -1

integer :: x(10)
call f(x, -3)
contains
subroutine f(y,n)
  integer :: y(1:n,2,*)
  call g(y)
end
subroutine g(z)
  integer :: z(..)
  print *, shape(z)
end
end

Reply via email to