This variant of maxloc_bounds_4.f90 module tst contains subroutine foo(res) integer(kind=4), allocatable :: f(:,:) integer(kind=8) , dimension(:) :: res allocate (f(2,5)) f = 3 res = maxloc(f) end subroutine foo end module tst program main use tst implicit none integer(kind=8) :: res(3) call foo(res) end program main does not trigger a bounds check with -fcheck=all. It is translated to ASSIGN foo:res(FULL) __convert_i4_i8[[((_gfortran_maxloc0_4_i4[[((foo:f(FULL)) ((arg not-present)) ((arg not-present)))]]))]] and the __convert_i4_i8 call hides the conversion from the library code for bounds checking, and does not do any bounds checking by itself.
Confirmed from 4.8 up to trunk (8.0). Many be related to pr82243.