[flang-commits] [PATCH] D133857: [flang] Limit shape inquiries rewrite to associate construct entity
Pete Steinfeld via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Sep 14 08:07:55 PDT 2022
PeteSteinfeld requested changes to this revision.
PeteSteinfeld added a comment.
This revision now requires changes to proceed.
The criterion you're using to figure out whether to rewrite the expression seems wrong to me. Rather than checking if the bounds are constant, I think that we should be checking to see if the right hand side of the ASSOCIATE clause is a variable. Here's a program that I believe will give the wrong result if we implement this change:
program test_associate
real, dimension(:), allocatable :: ra
allocate (ra(10))
print *, 'size(ra): ', size(ra)
associate (x => ra)
print *, 'size(x): ', size(x)
deallocate(ra)
allocate(ra(20))
print *, 'size(x): ', size(x)
end associate
end program test_associate
I believe that, for a conforming compiler, the final `print` statement should print `size(x): 20`. But with the changes you propose, we print `size(x): 10`.
Interestingly, the only compiler I can find that agrees with me is NAG. Every other compiler I've tried prints `size(x): 10`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133857/new/
https://reviews.llvm.org/D133857
More information about the flang-commits
mailing list