https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103662
--- Comment #4 from hubicka at kam dot mff.cuni.cz --- > Can you explain in simple words why adding > > if (ptr1%k .ne. 42) print * > > before the line > > if (ptr1%k .ne. 42) STOP 2 > > makes the test succeed, but adding it after that one the test fails? > Or adding > > print *, ptr1%k > > near the end of subroutine foo? I am not sure why it depends whether it is before or after the stop. Perhaps we thread the conditionals and optimize out print in some cases? However the reason why print matters is because print call confuses the simplistic escape analysis done in modref. It now understand the fact that calling an unknown function where all arguments are constant is safe and can not make function local parameters escaped. However it punt on calling anything with parameter. Before the patch the same testcase fails if you replace STOP 2 by anything that terminate program w/o calling function. For example by division by zero. I have patch to use PTA escape analysis in modref but it hits other problem with fortran FE and openMP - GOMP_parallel makes parameters escape even if Fortran FE produces fnspec delcaring them nonescape...