diff --git a/flang/lib/Semantics/compute-offsets.cpp b/flang/lib/Semantics/compute-offsets.cpp --- a/flang/lib/Semantics/compute-offsets.cpp +++ b/flang/lib/Semantics/compute-offsets.cpp @@ -154,7 +154,7 @@ auto eqIter{equivalenceBlock_.end()}; auto iter{dependents_.find(symbol)}; if (iter == dependents_.end()) { - auto eqIter = equivalenceBlock_.find(symbol); + eqIter = equivalenceBlock_.find(symbol); if (eqIter != equivalenceBlock_.end()) { DoEquivalenceBlockBase(symbol, eqIter->second); } diff --git a/flang/test/Semantics/offsets03.f90 b/flang/test/Semantics/offsets03.f90 --- a/flang/test/Semantics/offsets03.f90 +++ b/flang/test/Semantics/offsets03.f90 @@ -56,4 +56,8 @@ equivalence(i4, l4) equivalence(l4(10), k4) common /common6/ i4, j4 ! CHECK: common6 size=76 offset=0: CommonBlockDetails alignment=4: + + integer :: i5, j5, l5(10) + equivalence(l5(1), i5) + common /common7/ j5, i5 ! CHECK: common7 size=44 offset=0: CommonBlockDetails alignment=4: end