<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/98783>98783</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] backspace after non-advancing read
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    I tried the following program from the Intel-Fortran-Compiler community article and found that there is a difference in behavior between gfortran and flang-new.
(article: https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-backspace-after-non-advancing-read/td-p/1614668)

Reproducer:
```f90
program test_backspace
  implicit none
  integer a(4)
  integer iostat
 character c
  open(unit=1, file="test_backspace.csv", status='old', action='read', &
       position='rewind')
  do
     read(unit=1, fmt='(a)', advance='no', iostat=iostat) c
     if (iostat /= 0) exit
 end do
  backspace(unit=1)
  read(unit=1, fmt=*) a
 close(unit=1)
  print *, "a = ", a
end program test_backspace
```

Input file:
```console
$ cat test_backspace.csv
3 6
-2 0
```

Result:
```console
$ gfortran test_backspace.f90
$ ./a.out
 a =            3           6 -2           0
$ flang-new test_backspace.f90
$ ./a.out

fatal Fortran runtime error(/tmp/test_backspace.f90:13): End of file during input
Aborted
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVd2yozYMfhpzoyFjBAFywUW6KTPndl-gY4wg7hqbsc1J9-07BvJzTrdnWiZDiCx9-qJPEsJ7NRqihh1_Y8dLIpZwta75kQrn7M0nne1_Nm8QnKIewpVgsFrbmzIjzM6OTkwwODutR28mkE5b64ITJv1mp1lpciDtNC1GhZ8gXFBSEwjTw2AXExFFiLGOQHkQ0KthIEdGEigDHV3Fu7IOOgo3IgPjsIFvCFqYMTV0OzB-YfzMsN4TsPwM1xBmz_Izw5Zh--BwUJHkQdqJYRuODNtfs2bY3h_TbhnTTsgffhaS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