Issue 143733
Summary [flang] FIR verification failure for DTIO with structure constructor
Labels flang:fir-hlfir
Assignees
Reporter DanielCChen
    Consider the following code:
```
module m
   type base
      character(3), allocatable :: c
      contains
         procedure, pass :: write => writeb
         generic :: write(formatted) => write
   end type
 contains
      subroutine writeb (dtv, unit, iotype, v_list, iostat, iomsg)
         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
         character(20) :: fmt

 write (fmt, *) "(A", v_list(1), ")"
         write (unit, fmt, iostat=iostat, iomsg=iomsg) dtv%c
         iomsg = 'dtiowriteb'

      end subroutine

end module

program main
   use m
   integer :: stat
 character(200) :: msg

   open ( 1, file = 'main.1', form='formatted', access='sequential' )
   write ( 1, "(2(DT(3),DT(4)))", iostat = stat, iomsg = msg )  ( base('ABC'), base('DEF'), i=0,1 )
end program
```

Flang fails at:
```
Assertion failed: resultNumber < getNumResults() && "Result number is out of range for operation", file /home/cdchen/FLANG/llvm-project/flang/../mlir/include/mlir/IR/Operation.h, line 1011, detail::OpResultImpl *mlir::Operation::getOpResultImpl(unsigned int)()
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: flang -fc1 -triple powerpc64-ibm-aix7.2.0.0 -emit-obj -ffree-form -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -target-cpu pwr7 -resource-dir /home/cdchen/FLANG/build/lib/clang/21 -mframe-pointer=all -o /tmp/structConstr002-77e9b8.o -x f95 t.f
flang-21: error: unable to execute command: IOT/Abort trap

```

All ifort, gfortran and XLF compiles the code successfully.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to