<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/77038>77038</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] Storage association rules for named COMMON are violated
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
NimishMishra
</td>
</tr>
</table>
<pre>
Storage association by alternative view of named common block storage sequence in different scopes is broken; the wrong entities become associated.
Reproducer:
```
Program test_common_stg_assoc
Integer :: j(4)
Common/comm/j
j = [ (i,i=1,4,1) ]
Call diff
Print '(4I16)',j ! 1 and 4 must be intact
End Program test_common_stg_assoc
Subroutine diff
Integer :: k,l
Real(Kind(1.d0)) :: x
Common/comm/k,x,l
x = -999.
End Subroutine diff
```
`flang-new test.f90`: compiles normally and runs with following output:
```
1 2 0 -1064355840
```
`gfortran test.f90` issues a warning: "Padding of 4 bytes required before ‘x’ in COMMON ‘comm’ at (1); reorder elements or use ‘-fno-align-commons’". Usage of "fno-align-commons" gives output:
```
1 0 -1064355840 4
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVFFvozgQ_jXDyygIBijwwEObbKTVqbvVru65MjAQp8bO2qZp__3JJGm72b3V6aIIsGfm8zefZ0Y4J0fN3EBxB8UmErPfGdt8kZN0u3vpdlZErelfm-_eWDEyCudMJ4WXRmP7ikJ5tlp4-cz4LPmIZkAtJu6xM9MUfJTpntCdox3_mFl3jFJjL4eBLWuPrjMHdigdttY8sYbsDv2O8WiNHpG1l16yw5Y7M70z4D6GZAPJ7en5jQ_W9HPHFrLbjwa4Sc7_ZflgzWjFhJ6dfzyRfHR-fFxgTy6In7XnkS0GqOwW90BVDlRfzOslDGgb4oG2-4thj5BtEIo7BKok0FpCtkmB1jnQOgWqEYrNG4pQalHhsvFgpfYIVIbjPqc34cSwWO8RKMUUhe4xx2l2HtugoRedPwV_0j3-l8xOr-9za83speafzr_K-glorS62bywUUPWX1D1QlcZ9srCrL84v_6ZNQHn5iPSyaLSq6zp-5_5bRlc397Y5KKHHlebjkmo81ItPdhtq7iAVO9TGTkKp10UxO2uHR-l3OBilzFHqEc3sD7P_c6Wk-POPrtbJ8lylyU2eFUWVJ39mPQ7Geiv0R9IonZvZocCjsFrqMWQBRA-i7xeaA-bYvnp2aPnHLC332PJgLCN8IqgSqKuXy1cdumr99f7-65d363ILbw4ilFcVCjH0mGVje7bIiifW3qGxOLsP0KtBm5VQctSrUz25NyggivFvF5raDIHyr65EOMpndv9L7F_EvbLnVyhR32R9ndUi4iYtkzynIsuyaNe0pWjzNr-p6rorqpa7Mq-GIitvyrJLU6JINpRQnqRJkWRUFVncl1Xd1WUlyiGrsyqHPOFJSBUr9TzFxo7RcmtNWSZZFSnRsnLL_CRq5xGIgNZBkFClYVVsItuE2FU7jw7yREnn3Tual14tA_gUUWzwd8PWzqGwB2PP8_V80cKGwWtUmIfRbFWz8_7ggta0BdqO0u_mNu5MaMVw4vm1Oliz584DbU8lCLRd8vknAAD__4uyw_o">