https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85631
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |27766 --- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- The bouns checking is inserted in the wrong place, before setting the descriptor: $ cat b.f90 module x contains subroutine sub(a) real, dimension(:,:), intent(in) :: a real, allocatable, dimension(:,:) :: var_1_mma var_1_mma = transpose(a) end subroutine sub end module x program main use x implicit none real, dimension(:,:), allocatable :: block_1 block_1 = reshape([-2,3,-5,7], [2,2]) call sub(block_1) end program $ grep mma b.f90.003t.original struct array02_real(kind=4) var_1_mma; var_1_mma.data = 0B; D.3809 = (real(kind=4)[0:] * restrict) var_1_mma.data; D.3810 = var_1_mma.offset; D.3811 = var_1_mma.dim[0].lbound; D.3812 = var_1_mma.dim[0].ubound; D.3813 = var_1_mma.dim[1].lbound; D.3814 = var_1_mma.dim[1].ubound; if ((integer(kind=8)) (D.3811 <= D.3812 && var_1_mma.dim[0].lbound > D.3811)) _gfortran_runtime_error_at (&"At line 6 of file b.f90"[1]{lb: 1 sz: 1}, &"Index \'%ld\' of dimension 1 of array \'var_1_mma\' outside of expected range (%ld:%ld)"[1]{lb: 1 sz: 1}, D.3811, var_1_mma.dim[0].lbound, var_1_mma.dim[0].ubound); ... var_1_mma.dim[0].lbound = 1; var_1_mma.dim[0].ubound = NON_LVALUE_EXPR <D.3807>; var_1_mma.dim[0].stride = 1; var_1_mma.dim[1].lbound = 1; var_1_mma.dim[1].ubound = NON_LVALUE_EXPR <D.3808>; var_1_mma.dim[1].stride = NON_LVALUE_EXPR <D.3807>; As a matter of fact, we are taking the variables from the assignmemt, there should be no checking at all. Hmm... Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27766 [Bug 27766] [meta-bug] -fbounds-check related bugs