Issue 154954
Summary [flang] Failed at runtime when handling user-defined `v_list` with `DT` edit descriptor.
Labels flang:runtime
Assignees
Reporter DanielCChen
    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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to