Issue |
126582
|
Summary |
[Flang] Missing finalization on `LBOUND` when the argument is a reference to a function that has finalizable result.
|
Labels |
flang:frontend
|
Assignees |
|
Reporter |
DanielCChen
|
Consider the following code
```
module m
type base
integer*4 :: id = 1
contains
final :: finalizeBaseRank1
end type
contains
subroutine finalizeBaseRank1 (b)
type (base), intent(in) :: b(:)
print *, 'finalizeBaseRank1'
end subroutine
type (base) function func (i)
integer*4, intent(in) :: i
dimension func(10:i+10)
func%id = 0
end function
end module
program main
use m
integer :: res
res = lbound(func(4), 1) ! Missing finalization call
res = ubound(func(4), 1) ! Has the finalization call as expected
end
```
Flang seems missing the call to the finalization routine for `lbound` because likely the call is folded at compiler time because the result is 1. However, the standard requires the finalization for the result of reference such a function.
```
If an executable construct references a nonpointer function, the result is finalized after execution of the innermost executable construct containing the reference.
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs