https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109500
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #1 from kargl at gcc dot gnu.org --- Fortunately, this is not a bug in gfortran. Unfortunately, this is a bug in your program. A function is required by the Fortran standard to have its result variable assigned when it returns. If you compile your code with the -Wall option, you'll see gfortran -o z -Wall a.f90 a.f90:5:2: 5 | function f() | 1 Warning: Return value of function 'f' at (1) not set [-Wreturn-type] On my system, 'z' either segfaults or prints 'T'. For 'T' the function f() is pointing to whatever is left on the stack.