[flang-commits] [flang] [flang] Fix sequence association for PARAMETER array elements (PR #187348)
via flang-commits
flang-commits at lists.llvm.org
Thu Mar 19 06:56:47 PDT 2026
jeanPerier wrote:
> Actually, what I _meant_ to do originally is to limit this to `intent(in)` dummy args, which is reflected in my tests, but not in the code. :( The copy-out wouldn't be needed in this case.
Right, this would prevent copy-out inside directly inside the procedure being called to be a problem, but this is still only pushing the copy-out problem further/making it less likely because you can pass an INTENT(IN) variable in calls that do not have that attribute, so the copy-out may still happen further down the call chain and a segfault be hit. For instance:
```
subroutine foo_intent_int(x)
integer, intent(in) :: x(10)
call foo(x)
end subroutine
subroutine foo(x)
integer :: x(10)
call bar(x(1:10:2))
end subroutine
subroutine bar(x)
integer :: x(5)
print *, x
end subroutine
interface
subroutine foo_intent_int(x)
integer, intent(in) :: x(10)
end subroutine
end interface
integer, parameter :: x(10) = [(i, i=1,10)]
call foo_intent_int(x(1))
end
```
That is why I think that if we need to get rid of any copy of constants when passing them, then think we should better completely get rid of the copy and address the copy-out problem some other way (another alternative is to copy the whole constant array base, but I think we will just end up tanking perf and memory usage for the sake of a debatable and rare use case).
https://github.com/llvm/llvm-project/pull/187348
More information about the flang-commits
mailing list