Skip to content

[flang] Incorrect array bound after remapping of zero-sized array pointer #153221

@DanielCChen

Description

@DanielCChen

Consider the following reducer:

   program main

        double precision, target :: tar2(100)
        double precision, pointer :: ptr(:,:,:)

        i = -2
        call sub (i)

        contains
            function set_bd(i)
                integer i, set_bd
                allocatable set_bd
                allocate(set_bd, source = i)
            end function

            subroutine sub(i)
                integer i
                ptr(i:i-1, 1:set_bd(0), int(3.2):i) => tar2
                print*, lbound(ptr)
                print*, ubound(ptr)
            end subroutine
        End program

Flang outpus

> a.out
 1 1 3
 0 0 -2

The expected output should be

> a.out
 1 1 1
 0 0 0

All ifort, gfortran and XLF produces the correct result.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions