| Issue |
166804
|
| Summary |
[flang] DTIO failure with parent component
|
| Labels |
flang:runtime
|
| Assignees |
|
| Reporter |
DanielCChen
|
Consider the following code:
```
module m
type :: data
integer :: i, j
end type
type :: base
type(data) :: d1
end type
type, extends(base) :: child
type(data) :: d2
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 array001b
use m
integer :: stat
character(200) :: msg = ''
type(child) :: b3(4)
namelist /nml2/ b3
b3 = (/ child(data(1009,1010), data(1011,1012)), child(data(1013,1014), data(1015,1016)), &
child(data(1017,1018), data(1019,1020)), child(data(1021,1022), data(1023,1024))/)
write (6,NML=nml2, iostat=stat, iomsg=msg)
if ( stat /= 0 ) ERROR STOP 2
end program
subroutine writeformatted (dtv, unit, iotype, v_list, iostat, iomsg)
use m, only: base, child
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
select type ( m => dtv )
class is (base)
write (unit, *, iostat=iostat ) m%d1
type is (child)
!print*, "child" !! This line changes Flang's output
write (unit, *, iostat=iostat ) m%d1
write (unit, *, iostat=iostat ) m%d2
end select
end subroutine
```
Flang outputs 14 elements as:
```
> a.out
&NML2 B3= 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021/
```
Where there should be 16 elements as:
```
> a.out
&NML2 B3= 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024/
```
It seems the namelist got corrupted as if I enable the `print` inside of the `select type`, Flang outputs less element as:
```
> a.out
&NML2 B3= child 1009 1010 1011 1012 child 1013 1014 1015 1016 child 1017 1018/
```
Both gfortran and XLF produce the expected output.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs