https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98046
--- Comment #3 from Anthony M de Beus <anthony.debeus at gmail dot com> --- Very interesting discussion in bug 30617. Particularly the view that "If you compile code with undefined behavior in it, run it and that code crashes, hangs or formats your disk, that is a bug in the code you are running, not in the compiler. Anything can happen when you invoke undefined behavior. And anything includes hanging, segfault, formatting your disk etc." or "It appears that the code is invalid Fortran, so gfortran can do anything" Yes, but should it? If you take the view that the compiler is working perfectly if it compiles correct code correctly, then that make sense. However, if the compiler's job is also understood to check code for problems, hence compiler flags to check bounds, or issue warnings, eg -Wall, then the current situation vis a vis nested calls to io seems inadequate. Surely we don't want a compiler that rewards relatively subtle and hard to isolate bugs by formatting the hard disk! On the other hand, if the correct compiler behavior is to hang the program with the nested io calls, then shouldn't it do it consistently? Ignoring the invalid io call most of the time but only hanging when a particular version of a library (which isn't even invoked) is linked is unpredictable behavior by the compiler, IMO. Comment 41 in the duplicate thread seems quite apropos and prescient. Thank you both for very informative anf helpful comments.