[flang-commits] [flang] [flang] Fix incorrect offset for zero-size COMMON block members. (PR #214174)
Daniel Chen via flang-commits
flang-commits at lists.llvm.org
Wed Aug 5 13:55:55 PDT 2026
DanielCChen wrote:
> Additionally, before this PR we had error with this soruce:
>
> ```
> program p09
> integer(8) :: i8
> character(0) :: zc0
> character(8) :: c8
> common /blk/ i8, zc0
> equivalence (c8(5:8), zc0)
> print '(A,I0)', 'p09 c8-i8: ', loc(c8) - loc(i8)
> end program
> ```
>
> Error:
>
> ```
> error: Semantic errors in p09_backextend.f90
> p09_backextend.f90:9:11: error: 'zc0' cannot backward-extend COMMON block /blk/ via EQUIVALENCE with 'c8'
> common /blk/ i8, zc0
> ^^^
> ```
>
> This error seems to be wrong, since zc0 is not backward extending in this case. This PR is the fix for this error, so the PR description should probably mention this and also perhaps add a test for this case.
As for `p09`, this PR indeed fixed the error and flang now outputs `p09 c8-i8: 4`, which is consistent across all vendors.
https://github.com/llvm/llvm-project/pull/214174
More information about the flang-commits
mailing list