Issue 77038
Summary [flang] Storage association rules for named COMMON are violated
Labels bug, flang
Assignees
Reporter NimishMishra
    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
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to