https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66089
--- Comment #10 from Mikael Morin <mikael at gcc dot gnu.org> --- Here is a variant that fails similarly (even with the patch) with optional arguments. type :: t integer :: c end type t type(t), dimension(5) :: a, b, c a = t(1) b = t(7) c = t(13) call do_bug(c, b) print *, c if (any(c%c /= 20)) call abort contains elemental function plus(lhs, rhs) optional :: lhs type(t), intent(in) :: lhs, rhs type(t) :: plus if (present(lhs)) then plus%c = lhs%c + rhs%c else plus%c = 0 end if end function plus subroutine do_bug(lhs, rhs) type(t), intent(inout), optional :: lhs(5) type(t), intent(in) :: rhs(5) if (present(lhs)) then lhs = plus(lhs(1), rhs) end if end subroutine end