https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69739
--- Comment #2 from John <jwmwalrus at gmail dot com> --- After reporting the bug, I noticed that in the actual code I have (not the reduced version I posted before), adding the (:) stride doesn't always make the ICE go away. What solved the problem once and for all (and without using the -fno-realloc-lhs flag) was changing the result in the "operate" function to be that of an allocatable array: function operate(A, X) type(sometype), intent(IN) :: A(:,:,:) real, intent(IN) :: X(:) ! real :: operate(1:PRODUCT(UBOUND(A))) real, allocatable :: operate(:) allocate (operate(1:PRODUCT(UBOUND(A)))) operate(:) = 0 end function So maybe the automatic-size result is the actual root of the ICE?