--- libgfortran/io/file_pos.c.save 2018-07-03 22:48:42.485018736 +0000 +++ libgfortran/io/file_pos.c 2018-07-04 07:51:43.494582145 +0000 @@ -511,7 +511,8 @@ st_flush (st_parameter_filepos *fpp) else { needs_unlock = true; - LOCK (&u->au->io_lock); + if (u->au) + LOCK (&u->au->io_lock); } /* Make sure format buffer is flushed. */