Skip to content

[flang] Incorrect element byte length when checking the FIELD argument of UNPACK intrinsic. #149353

@DanielCChen

Description

@DanielCChen

Consider the following code:

    program main

        type A
            integer x
        end type

        type, extends(A) :: B
            integer :: y
        end type

        logical*4 :: mask(2,1,3)

        type(A), pointer :: fV(:,:,:)
        class(A), target, allocatable :: bT(:)

        allocate(bT(12), source=(/ (B(i, i+1), i=1,12) /) )

        fv(2:3, (0):0, 3:5) => bT(::2)
        mask = reshape ( (/ .false., .false., .true., .true., &
                    .false., .false. /), (/ 2,1,3 /))

        print*, sizeof(fv(1,1,1))
        fv = unpack((/ A(101), A(-101) /), mask, fv)
    end program

Flang failed at the execution as:

> a.out
 4

fatal Fortran runtime error(t.f:23): UNPACK: VECTOR= has element byte length 4 but FIELD= has length 8
IOT/Abort trap(coredump)

However, as it is printed, the sizeof an element of FIELD fv is 4.

All ifort, gfortran and XLF executed the code successfully.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions