public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tkoenig at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/105361] New: Incorrect end-of-file condition for derived-type I/O
Date: Sat, 23 Apr 2022 16:29:13 +0000	[thread overview]
Message-ID: <bug-105361-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2022-04-23 16:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-23 16:29 tkoenig at gcc dot gnu.org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105361-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).