https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #28 from Susi Lehtola <jussilehtola at fedoraproject dot org> --- Harald, Andreas, thanks for clarifying: yes, "crash" == Fortran runtime error. The program should run just fine, since the return array has the proper size given by get_environment_variable. Instead, it ends in a runtime error in get_environment_variable. The root cause is that get_environment_variable_i4 in libgfortran/intrinsics/env.c checks for a zero size return array before it checks what size an array is needed: when the environment variable is set to an empty string, a zero-size Fortran array is sufficient. The return value size check should just be moved a few lines down to where the memcpy() is performed.