https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78258
--- Comment #1 from Gerhard Steinmetz <gerhard.steinmetz.fort...@t-online.de> --- For completeness, two correct and working variants : $ cat y1.f90 program p implicit none call sub (1, 'abcd') call sub (2, x4=4, x3='1234567') contains subroutine sub (x1, x2, x3, x4) integer, intent(in) :: x1 character(4), optional :: x2 character(7), optional :: x3 integer, optional :: x4 if ( x1 == 1 ) then if ( x2 /= 'abcd' ) call abort else if ( x3 /= '1234567' ) call abort if ( x4 /= 4 ) call abort end if end end $ cat y2.f90 program p implicit none call sub (1, 'abcd') call sub (2, x4=4, x3='1234567') contains subroutine sub (x1, x2, x3, x4) integer, intent(in) :: x1 character(4), optional :: x2 character(*), optional :: x3 integer, optional :: x4 if ( x1 == 1 ) then if ( x2 /= 'abcd' ) call abort else if ( x3 /= '1234567' ) call abort if ( x4 /= 4 ) call abort end if end end