https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90744
--- Comment #2 from Tomáš Trnka <trnka at scm dot com> --- Looks like the issue appears if a particular external procedure is called for the second time. Replacing the seemingly useless "if" with just two calls leads to one correct and one miscompiled call: subroutine DoTest() call convrs('A',getstr()) call convrs('B',getstr()) end subroutine dotest () { { static integer(kind=8) slen.0; character(kind=1)[1:slen.0] * pstr.1; typedef character(kind=1) struct character(kind=1)[1:slen.0][1:slen.0]; pstr.1 = 0B; slen.0 = 0; getstr (&pstr.1, &slen.0); convrs (&"A"[1]{lb: 1 sz: 1}, pstr.1, 1, slen.0); __builtin_free ((void *) pstr.1); } { static integer(kind=8) slen.2; character(kind=1)[1:slen.2] * pstr.3; typedef character(kind=1) struct character(kind=1)[1:slen.2][1:slen.2]; pstr.3 = 0B; slen.2 = 0; getstr (&pstr.3, &slen.2); convrs (&"B"[1]{lb: 1 sz: 1}, pstr.3, 1, &slen.2); __builtin_free ((void *) pstr.3); } }