https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96018
--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- I can not test at the moment, that will have to wait for a few days. A general comment: In Fortran, functions exist to return a value. C-style „return an error status“ fit rather badly to the language, that is much better expressed wirh a subroutine (plus an optional error reporting argument). Having said that, one thing that might influence the behavior is front-end optimization. What happens if -fno-frontend-optimize -O is specified?