Skip to content

[flang] Incorrectly referenced function multiple times when it is used for array indexing. #153031

@DanielCChen

Description

@DanielCChen

Consider the following reducer:

integer :: count = 0
type dt
  integer, allocatable :: i(:)
end type
type(dt) :: x(10)
integer :: ub

allocate(x(2)%i(2:3))
ub = ubound(x(foo())%i,1)        !! Called twice here.
if (count /= 1) error stop 5
contains
  integer function foo()
    foo = 2
    count = count + 1
  end function
end

Flang called function foo twice when it is referenced to get the array index for x. The count should be 1.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions