Issue 152758
Summary [flang] Derived type intrinsic assignment error with pointer component assignment to the parent component
Labels flang:frontend
Assignees
Reporter DanielCChen
    Consider the following reducer:
```
module m
    type base
        integer, pointer :: ids(:) => null()
    end type

    type, extends(base) :: child
        character(7), allocatable :: name
    end type

 contains

    subroutine copyBase (b1, b2)
        type(base), allocatable, intent(inout) :: b1(:)
        class(base), intent(in) :: b2(:)
        integer :: i

        b1 = b2

        do i = 1, 10, 2
 print*, b2(i)%ids
          print*, b1(i)%ids
        end do
 end subroutine
end module

program dummyArg002
use m

    type(base), allocatable :: b1(:)
    class(base), pointer :: b2(:)

    !! test 3: for derived types
    allocate (b2(10), source=(/(child(null(), 'xlftest'), i=1,10)/))

    do i = 1, 10, 2
        allocate (b2(i)%ids(i), source=(/(j, j=1,i)/))
        print*, b2(i)%ids
    end do

    call copyBase(b1, b2)

end
```

Flang failed at the execution with 
```
> a.out
 1
 1 2 3
 1 2 3 4 5
 1 2 3 4 5 6 7
 1 2 3 4 5 6 7 8 9
 1
 1
 1 2 3

fatal Fortran runtime error(t.f:21): DescriptorIO: bad type code (0) in descriptor
IOT/Abort trap(coredump)
```

It seems the derived type intrinsic assignment `b1 = b2` didn't get the pointer component `ids` assigned properly.
If I changed the declaration of `b1` to `class(base), allocatable :: b1(:)`, it works fine.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to