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

    <tr>
        <th>Summary</th>
        <td>
            [flang] Failed at runtime when handling user-defined `v_list` with `DT` edit descriptor.
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          DanielCChen
      </td>
    </tr>
</table>

<pre>
    Consider the following code:
```
module m
   type base
      integer :: i
   end type

   interface write(formatted)
      subroutine writeformatted(dtv, unit, iotype, v_list, iostat, iomsg )
         import base
 class(base), intent(in) :: dtv
         integer,  intent(in) :: unit
 character(*), intent(in) :: iotype
         integer, intent(in)     :: v_list(:)
         integer,  intent(out) :: iostat
         character(*), intent(inout) :: iomsg
      end subroutine
   end interface

end module

program fdtedit105kl
use m

   type(base) :: b1 = base(100)
 type(base) :: b2 = base(200)

   integer :: stat
   character(150) :: msg = 'original'
   open (1, file = 'fdtedit105kl.1', form='formatted', access='sequential' )

10 format (DT'write'(-1,+2,3,-4,+5,6))

   write ( 1, 10, iostat = stat, iomsg = msg )   b1
print*, stat
print*, msg
   if ( stat /= 0 ) ERROR STOP 1

   close ( 1, status='delete' )

end program

subroutine writeformatted (dtv, unit, iotype, v_list, iostat, iomsg)
use m, only: base

   class(base), intent(in) :: dtv
   integer, intent(in) :: unit
   character(*), intent(in) :: iotype
   integer, intent(in)     :: v_list(:)
   integer, intent(out) :: iostat
 character(*), intent(inout) :: iomsg

   write ( unit, "(I4)", iostat = iostat ) dtv%i

end subroutine
```

Flang failed at the runtime as:
```
> a.out
 1005
 Excessive DT(v_list) in FORMAT; at offset 1 in format '(dt'write'(1,+2,3,-4,+5
 ,6))'
Fortran ERROR STOP: code 1
```

The test case is testing if the `v_list` that the main program defined via the `DT` edit descriptor gets passed to the DTIO procedure correctly.
</pre>
<img width="1" height="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