<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/142488>142488</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] Incorrect COMMON block storage sequence
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DanielCChen
</td>
</tr>
</table>
<pre>
Consider the following code:
```
INTEGER i,j,k
INTEGER i7(10)
INTEGER i8(10)
INTEGER i9(20)
COMMON /BLOCK1/ i7,i8
EQUIVALENCE (i7,i9)
DO i = 1,20
i9(i) = i
END DO
FORALL ( i = 1:10 )
i8(i) = i9(9+i)
END FORALL
PRINT *,i8
PRINT *,i9
END
```
Expected output:
```
10 10 10 10 10 10 10 10 10 10
1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 10
```
Flang outputs:
```
10 11 12 13 14 15 16 17 18 19
1 2 3 4 5 6 7 8 9 10 10 11 12 13 14 15 16 17 18 19
```
The standard requires the storage sequence of a COMMON block to be the order of its object list.
```
The order of the storage sequences is the same as the order of the appearance of the common block object lists in the scoping unit.
```
Therefore, the assignment to `i8` in `FORALL` should affect both `i8` and `i9`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VF2PozYU_TXm5Woj-0L4eOAhQ0I16mzSjqZ9N_gSvEtw1jbb9t9XBnZ2Es2OhIR8fe45x_axpXP6PBKVbPvAtvtITr43ttzLUdNQVT2NUWPUf2VlRqcVWfA9QWeGwfyjxzO0RhGLd4zvWMrXj-8A4PH4cvjt8AyaYfWFYfU1QG5nMoa54AyLu3r-i3rBMMe1vkxVp8-fT0dgWD88narfBcN6pq10vgAOf_71-Pfu6XCsDsAwX-aKV4oFtD-BBhbvQTCscPUPsAhqhsU8qVfG4x72p9fe-vS8e3oK3K8c8U5weHUfePIbnsBaMHzQr5jAuRAt4z-eH48vwHD3ZiU3tdX-4bi_2_hQ_PdKrScFZvLXyb9zOIJ_8M0AQIghgS2kkEEOxcctS9edjXqQ43n14H5hQoBAEDGIBMQWRAoiA5GDKD408VHXnYmXnsB5OSppFVj6NmlLbk6w88bKM4GjbxONLYHpQP7IUzOY9it4Aw3NYGND8E0H2jswzRdqPQza-Q3cSb68Bb8n40Cv-vJCIN0tfRjI65WklaulUGnN5WLG1dQbdQd6XLhacw13cRq137y7CZY6Y4lhtUjMV_5Cow9rZCnXOUt5YGMpX3OYcnC9mQYFsuuCYmN8_xMrRzUPCpbyIBmpMlZFXMiISpEleV4UPE-iviTeSJF1KuVZsy1iykl1LaqCKEuaQjWRLpHjlqccUYicJ5tMqUxmmCaK4qJrCpZwukg9bIbh-2Vj7DnSzk1UigSTPI8G2dDg5tcLsQuhY_Gus2b0NCqGGN40W4beT810dizh8979ZPPaD_PrtzRv9_A4tsbasOibPNyfZTTZoey9v87xxpphfda-n5pNay4M66Cw_j5drQnnxrCezTuG9er_e4n_BwAA__90x4Q-">