<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57749>57749</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] Segmentation fault on assigning array with common, equivalence statements present
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jpenix-quic
      </td>
    </tr>
</table>

<pre>
    I am seeing a segfault when building and running the program below using flang. I am seeing this issue with for both x86_64 and aarch64 and have been building with the `-static` flag. 

```
subroutine foo
  implicit NONE

  real*8  common_arr1(133),common_arr2(133)
  common /my_common_block/ common_arr1,common_arr2
  real*8 arr1(133),arr2(133)
  real*8 arr3(133,133),arr4(133,133)
  equivalence(arr1,common_arr1),(arr2,common_arr2)
  equivalence(arr3,arr4)

  arr4 = 3
  print *, "Passed"
  return
end

program test
  call foo()
end
```

gfortran and ifort both seem to handle this ok (please see godbolt [here](https://godbolt.org/z/MaYeTdnch)). I originally ran into this when looking at 434.zeusmp in SPEC2006. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1VEtzmzAQ_jVw0cQDEmA4cEjjZKaHpplJLz1lBCygREiuJJI4v74rYcePtDPY7PPbN43udvV3widiAYQaCEdi6PksHXkbQZFmFrILCtURMyvlaTcC2Ro9GPRrQOo3Mlsv7yVXw4qc4rlRWCKsnYG8CTeSXhvSaCTey-KpyAIs56Yd9_TIXwExTyMHPx8yKpIr67gTLVI-GMaKkk2UXO__i2T_BNbOjdGzEwowql5khIhpK0UrHLn_eX976k2IAS4jel0S0upp0uqJG5NGtEwZi2gV0ZujmB7Fe-dFRyJ6N-2e9oaN1O0LSs7xzmAuQ1-G_GesU2t20N6c-mSX0r0n_JnFK5egWkCLL_mkC8CiopcV_x-FfUatzlvqhSRiG8IOkq0RymGbrtEFX_SBWwsdEsfi3GzUwoHqTvEOO-fAus--cynDfGn5Gf3odr4Ry_-AO-gMV2HfhGeWjcSNRWiNK6g6Ccvm6hfMsdxK4Ba8ARl012g8jij_NoKBKN-gfnRuayOGJd3hszdZaTMg94G_H_w3_OpUO4b2Vv5CtBGDUJj7jvhUsCd6iRiuTmr9Eo7OkYxlqw-Y7bRFI_L4cHtDk6RYkRjqtChYWpXrhMZdzbqKVTx2wkmoMbtwi5geeYRhAuXPBtdzuWwksOtiCMeMI-K75ciWafvBnEyY-JMDD2FxeGCRiGcj64ui0X9uVoiAjJSvh9cVzuwZWods-ApYJPL1OqvisV6zvOzw1ts-4W3TZ_m66au8Y3nGE8ryKpYcvy7WV4P7sRSEe5JvYlHThNKkSjPKWEnpql-36y5Nk75gTZpWeZQlMHEhVz4HP4nY1CGdZh4sKqWwzh6VSzcgNM7j89mN2tTPW1Di_Qp70cYh-zqk_he66Jyr">