https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83057
Harald Anlauf <anlauf at gmx dot de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gmx dot de --- Comment #4 from Harald Anlauf <anlauf at gmx dot de> --- The following obvious patch to the logic fixes the NEWUNIT issue: Index: gcc/fortran/io.c =================================================================== --- gcc/fortran/io.c (revision 269028) +++ gcc/fortran/io.c (working copy) @@ -2504,16 +2504,15 @@ goto cleanup; } - if (!open->file && open->status) - { - if (open->status->expr_type == EXPR_CONSTANT + if (!open->file && + (!open->status || + (open->status->expr_type == EXPR_CONSTANT && gfc_wide_strncasecmp (open->status->value.character.string, - "scratch", 7) != 0) - { + "scratch", 7) != 0))) + { gfc_error ("NEWUNIT specifier must have FILE= " "or STATUS='scratch' at %C"); goto cleanup; - } } } else if (!open->unit) I do not think we need to handle the other case, as many people expect the file fort.20 to be created. (At least I do.)