https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94672
Tomáš Trnka <trnka at scm dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |trnka at scm dot com --- Comment #12 from Tomáš Trnka <trnka at scm dot com> --- The fix for this broke assumed length optional character arguments. I have noticed this on 10.2.1 20200723, which is currently used by Fedora 32. Bisected using the following testcase: subroutine foo (n, lVal, sVal) integer, intent(in) :: n logical, optional, intent(out) :: lVal(n) character(*), optional, intent(out) :: sVal(n) integer :: nFound nFound = 0 if (present(lVal)) then nFound = nFound + 1 end if if (present(sVal)) then nFound = nFound + 1 end if write(*,*) nFound end subroutine Affected versions compile this to the following: character(kind=1)[0:D.3919][1:_sval] * restrict sval.0; … if (sval.0 != 0B) { ubound.2 = (integer(kind=8)) *n; size.3 = NON_LVALUE_EXPR <ubound.2>; size.3 = MAX_EXPR <size.3, 0>; D.3917 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <_sval> * 8; D.3918 = (sizetype) NON_LVALUE_EXPR <_sval>; D.3919 = size.3 + -1; D.3920 = ((bitsizetype) (sizetype) NON_LVALUE_EXPR <_sval> * (bitsizetype) (sizetype) NON_LVALUE_EXPR <size.3>) * 8; D.3921 = (sizetype) NON_LVALUE_EXPR <_sval> * (sizetype) NON_LVALUE_EXPR <size.3>; sval.0 = (character(kind=1)[0:D.3919][1:_sval] * restrict) sval; } … if (sval.0 != 0B) { nfound = nfound + 1; } The first test thus relies on an unitialized value of sval.0. If that value happens to be zero, the actual "sval" argument will be ignored even if it is present.