https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101255

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org
           Priority|P3                          |P4

--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to Tobias Burnus from comment #0)
> F2018 states:
> 
> "Fortran 2008 specifies that the IOSTAT= variable shall be set to a
> processor-dependent negative value if the flush operation is not supported
> for the unit specified. This document specifies that the processor-dependent
> negative27integer value shall be different from the named constants
> IOSTAT_EOR or IOSTAT_END from the intrinsic28module ISO_FORTRAN_ENV."
> 
> However, the following program prints:
>         5002 Specified UNIT in FLUSH is not connected          
>           -2          -1
> shouldn't the 5002 be a negative number (such as -5002)?
> 
> use iso_fortran_env
> implicit none
> character(len=50) :: err
> integer :: i
> !open(99)
> !close(99)
> flush(99,iostat=i,iomsg=err)
> print *, i, err
> print *, IOSTAT_EOR , IOSTAT_END 
> end

diff --git a/libgfortran/io/file_pos.c b/libgfortran/io/file_pos.c
index 7e71ca577e0..4ed1698f17a 100644
--- a/libgfortran/io/file_pos.c
+++ b/libgfortran/io/file_pos.c
@@ -527,7 +527,7 @@ st_flush (st_parameter_filepos *fpp)
     }
   else
     /* FLUSH on unconnected unit is illegal: F95 std., 9.3.5. */ 
-    generate_error (&fpp->common, LIBERROR_BAD_OPTION,
+    generate_error (&fpp->common, -LIBERROR_BAD_UNIT,
                        "Specified UNIT in FLUSH is not connected");

   if (needs_unlock)

Reply via email to