To: J3 J3/22-102 From: T. Burnus & R. Bader Subject: Interp candidate: Lower bounds in sourced allocation Date: 2021-December-13 Reference: 18-007r1 1. Question Consider the following program: program source_is_function_result implicit none integer, allocatable :: c(:) allocate(c, source=h(3)) write(*,*) lbound(c,1), ubound(c,1) contains pure function h(i) result(r) integer, value, intent(in) :: i integer, allocatable :: r(:) allocate(r(3:5)) r = [1,2,3] end function h end What is the lower bound of c? 2. Discussion 9.7.1.2 of 18-007r1 specifies that "When an ALLOCATE statement is executed for an array with no allocate-shape-spec-list, the bounds of source-expr determine the bounds of the array." Looking at the definition of bounds in the standard, the general idea appears to be that in this situation the lower bound should be 1. However, for the above case of sourced allocation this is not obvious. For all other situations where lower bounds are explicitly needed (e.g., reallocation on intrinsic assignment, data pointer assignment) the deduction is possible because the text refers to LBOUND. That intrinsic's description produces the desired answer. 3. Suggested resolution and edit: It is suggested to modify the above specification to refer to LBOUND. [134:27-28] replace sentence "When ... array." by "When an ALLOCATE statement is executed for an array with no allocate-shape-spec-list, the lower bound of each dimension of array is the result of the intrinsic function LBOUND (16.9.109) applied to the corresponding dimension of source-expr; the shape of array is that of source-expr." We have avoided a reference to UBOUND because that intrinsic also would deliver a defined value for assumed-size objects appearing as a source-expr, which surely should be disallowed.