https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82995
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #44790|0 |1 is obsolete| | --- Comment #11 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- Created attachment 45291 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45291&action=edit Next attempt This patch handles the library side correctly, as far as cursory testing reveals. However, there still is something in there that I do not understand. For the test case module y implicit none contains function my_sum(input,mask) logical, intent(in), optional :: mask(:) integer, intent(in) :: input(:) integer :: my_sum my_sum = sum(input,mask) end function my_sum end module y program test_my_sum use y implicit none integer :: input(3) = [1,2,3] integer :: res res = my_sum(input) print *,res end program test_my_sum I get, on the caller's side { struct array01_integer(kind=4) parm.10; parm.10.span = 4; parm.10.dtype = {.elem_len=4, .rank=1, .type=1}; parm.10.dim[0].lbound = 1; parm.10.dim[0].ubound = 3; parm.10.dim[0].stride = 1; parm.10.data = (void *) &input[0]; parm.10.offset = -1; res = my_sum (&parm.10, 0B); } which looks good - there is a NULL pointer being passed to my_sum. In my_sum, I get { integer(kind=4) val.8; integer(kind=8) D.3900; integer(kind=8) D.3901; integer(kind=8) D.3902; integer(kind=8) D.3903; val.8 = 0; D.3900 = offset.6; D.3901 = ubound.4; D.3902 = offset.2; D.3903 = ubound.0; { integer(kind=8) S.9; integer(kind=8) D.3905; integer(kind=8) D.3906; D.3905 = stride.5; D.3906 = stride.1; S.9 = 1; while (1) { if (S.9 > D.3901) goto L.1; if ((mask == 0B || (logical(kind=4)[0:] * restrict) mask->data == 0B) || (*mask.0)[S.9 * D.3905 + D.3900]) { val.8 = (*input.0)[S.9 * D.3906 + D.3902] + val.8; } S.9 = S.9 + 1; } L.1:; } __result_my_sum = val.8; } return __result_my_sum; } which looks quite OK. Still, I get zero as a result. Something to do with arguments being passed wrong, maybe?