When compiled with -check all with ifort 22.214.171.124 the following code produces and internal compiler error:
module m implicit none contains function ftext(text) result(s) character(len=*), intent(in) :: text(:) integer :: l character(len = 6+sum((/(len_trim(text(l)),l=1,size(text))/))) :: s character(len=*), parameter :: format = '(a,*(a))' write(s,format) & 'Text: ', ( trim(text(l)) ,l=1,size(text)) end function ftext subroutine s() integer :: i character(len=1000) :: str str = ftext((/"abc"/) ) end subroutine s end module m
Thank you for the report and convenient reproducer. I can reproduce this with ifort 16.0 but not our newer ifort 17.0 (Beta) so we may already have a known fix coming. I'll investigate a bit further and reply with more details later.
Development was also unable to determine the exact edit responsible for fixing this in 17.0; however, we confirmed it remains fixed in 17.0 source branch and our current development sources, and we added the test case to our internal test suite to ensure it does not regress in the future.