https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105674
Bug ID: 105674 Summary: Wrong bounds for assumed rank pointer Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: martin.diehl at kuleuven dot be Target Milestone: --- Created attachment 53007 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53007&action=edit small reproducer When using a pointer with striding, the ranks in a rank selector are wrong (0-based instead of 1-based). In the following program, lbound/lbound differ between 'strided' '(strided)'. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89364 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94070 seem to be related. The example is also attached as a file. program test integer, dimension(2,2), target :: dim_2 integer, dimension(product(shape(dim_2))), target :: dim_1 integer, dimension(:,:), pointer :: strided integer :: i dim_1 = [(i,i=1,size(dim_1,1))] dim_2 = reshape(dim_1,shape(dim_2)) strided => dim_2(1:1,:) print*, 'lbound', lbound(strided) print*, 'ubound', ubound(strided) call assumed_rank(dim_1) call assumed_rank(dim_2) call assumed_rank(strided) call assumed_rank((strided)) contains subroutine assumed_rank(dataset) integer, intent(in), dimension(..) :: dataset select rank(dataset) rank(1) print*, 'rank 1' print*, 'lbound', lbound(dataset), 'ubound', ubound(dataset) print*, dataset rank(2) print*, 'rank 2', dataset print*, 'lbound', lbound(dataset), 'ubound', ubound(dataset) end select print*, '' end subroutine assumed_rank end program test