public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/105361] New: Incorrect end-of-file condition for derived-type I/O
@ 2022-04-23 16:29 tkoenig at gcc dot gnu.org
  2022-04-24 19:57 ` [Bug libfortran/105361] " tkoenig at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2022-04-23 16:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105361
           Summary: Incorrect end-of-file condition for derived-type I/O
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tkoenig at gcc dot gnu.org
  Target Milestone: ---

The following test case

module x
  implicit none
  type foo
     real :: r
  end type foo
  interface read(formatted)
     module procedure read_formatted
  end interface read(formatted)
contains
  subroutine read_formatted (dtv, unit, iotype, vlist, iostat, iomsg)
    class (foo), intent(inout) :: dtv
    integer, intent(in) :: unit
    character (len=*), intent(in) :: iotype
    integer, intent(in) :: vlist(:)
    integer, intent(out) :: iostat
    character (len=*), intent(inout) :: iomsg
    read (unit,*,iostat=iostat,iomsg=iomsg) dtv%r
    print *,dtv%r
  end subroutine read_formatted
end module x

program main
  use x
  implicit none
  type(foo) :: a, b
  read (*,*) a, b
  print *,a,b
end program main

yields, when invoked with

$ echo "1 2" | ./a.out
   1.00000000    
   2.00000000    
At line 25 of file test.f90 (unit = 5, file = 'stdin')
Fortran runtime error: End of file

[...]

The end-of-file condition is incorrect.  The print statement
in read_formatted is there just to show the input is read correctly.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/105361] Incorrect end-of-file condition for derived-type I/O
  2022-04-23 16:29 [Bug libfortran/105361] New: Incorrect end-of-file condition for derived-type I/O tkoenig at gcc dot gnu.org
@ 2022-04-24 19:57 ` tkoenig at gcc dot gnu.org
  2022-04-24 20:04 ` tkoenig at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2022-04-24 19:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
This "fixes" the bug in question, but is almost certainly entirely
incorrect for a lot of other cases.  Will have to look a bit further.

--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -2364,13 +2364,13 @@ finish_list_read (st_parameter_dt *dtp)
       if (likely (dtp->u.p.child_saved_iostat == LIBERROR_OK))
        {
          c = next_char (dtp);
          if (c == EOF)
            {
              free_line (dtp);
-             hit_eof (dtp);
+             // hit_eof (dtp);
              return;
            }
          if (c != '\n')
            eat_line (dtp);
        }
     }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/105361] Incorrect end-of-file condition for derived-type I/O
  2022-04-23 16:29 [Bug libfortran/105361] New: Incorrect end-of-file condition for derived-type I/O tkoenig at gcc dot gnu.org
  2022-04-24 19:57 ` [Bug libfortran/105361] " tkoenig at gcc dot gnu.org
@ 2022-04-24 20:04 ` tkoenig at gcc dot gnu.org
  2022-05-06  1:32 ` jvdelisle2 at gmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2022-04-24 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
As expected:

FAIL: gfortran.dg/list_read_8.f90   -O0  execution test
FAIL: gfortran.dg/list_read_8.f90   -O1  execution test
FAIL: gfortran.dg/list_read_8.f90   -O2  execution test
FAIL: gfortran.dg/list_read_8.f90   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions  execution test
FAIL: gfortran.dg/list_read_8.f90   -O3 -g  execution test
FAIL: gfortran.dg/list_read_8.f90   -Os  execution test
FAIL: gfortran.dg/streamio_16.f90   -O0  execution test
FAIL: gfortran.dg/streamio_16.f90   -O1  execution test
FAIL: gfortran.dg/streamio_16.f90   -O2  execution test
FAIL: gfortran.dg/streamio_16.f90   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions  execution test
FAIL: gfortran.dg/streamio_16.f90   -O3 -g  execution test
FAIL: gfortran.dg/streamio_16.f90   -Os  execution test

It might work to not call hit_eof only in the specific case
(doing list-directed input in the user-defined I/O from
within a list-directed input).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/105361] Incorrect end-of-file condition for derived-type I/O
  2022-04-23 16:29 [Bug libfortran/105361] New: Incorrect end-of-file condition for derived-type I/O tkoenig at gcc dot gnu.org
  2022-04-24 19:57 ` [Bug libfortran/105361] " tkoenig at gcc dot gnu.org
  2022-04-24 20:04 ` tkoenig at gcc dot gnu.org
@ 2022-05-06  1:32 ` jvdelisle2 at gmail dot com
  2024-03-06  2:53 ` jvdelisle at gcc dot gnu.org
  2024-03-12  1:08 ` jvdelisle at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle2 at gmail dot com @ 2022-05-06  1:32 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle2 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle2 at gmail dot com

--- Comment #3 from Jerry DeLisle <jvdelisle2 at gmail dot com> ---
Hi Thomas, this is another one I would like to look at since I implemented a
lot of this in the beginning. I want to look at the dump and see why the
condition is not being set. I have a hunch on this.  It has to do with the DTP
structure where the status kept.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/105361] Incorrect end-of-file condition for derived-type I/O
  2022-04-23 16:29 [Bug libfortran/105361] New: Incorrect end-of-file condition for derived-type I/O tkoenig at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-05-06  1:32 ` jvdelisle2 at gmail dot com
@ 2024-03-06  2:53 ` jvdelisle at gcc dot gnu.org
  2024-03-12  1:08 ` jvdelisle at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2024-03-06  2:53 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jvdelisle at gcc dot gnu.org

--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Triaging the list of 1300 gforran bugs and spotted this one, so getting on my
list. (Especially since I have been buried in the related code).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/105361] Incorrect end-of-file condition for derived-type I/O
  2022-04-23 16:29 [Bug libfortran/105361] New: Incorrect end-of-file condition for derived-type I/O tkoenig at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-03-06  2:53 ` jvdelisle at gcc dot gnu.org
@ 2024-03-12  1:08 ` jvdelisle at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2024-03-12  1:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105361
Bug 105361 depends on bug 105456, which changed state.

Bug 105456 Summary: Child I/O does not propage iostat
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105456

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-12  1:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-23 16:29 [Bug libfortran/105361] New: Incorrect end-of-file condition for derived-type I/O tkoenig at gcc dot gnu.org
2022-04-24 19:57 ` [Bug libfortran/105361] " tkoenig at gcc dot gnu.org
2022-04-24 20:04 ` tkoenig at gcc dot gnu.org
2022-05-06  1:32 ` jvdelisle2 at gmail dot com
2024-03-06  2:53 ` jvdelisle at gcc dot gnu.org
2024-03-12  1:08 ` jvdelisle at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).