https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61933
--- Comment #7 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> --- Hi Jerry, thanks for the fix, but this seems to break code to find a free unit, like such: MODULE M CONTAINS FUNCTION get_unit_number(file_name) RESULT(unit_number) CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: file_name INTEGER :: unit_number INTEGER :: ic, istat, nc LOGICAL :: exists, is_open ! Get a new unit number DO unit_number=10,100 INQUIRE (UNIT=unit_number,EXIST=exists,OPENED=is_open,IOSTAT=istat) IF (exists.AND.(.NOT.is_open).AND.(istat == 0)) RETURN END DO unit_number = -1 END FUNCTION get_unit_number END MODULE USE M write(6,*) "unit to use: ",get_unit_number("foo.dat") END This will now always return -1, while it used to return a free unit.