[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:49:52 PDT 2026
DanielCChen wrote:
> Another test to check:
>
> ```
> program p20
> character(1) :: c1
> real(8) :: z0(0)
> character(1) :: c2
> common /blk/ c1, z0, c2
> print '(A,I0,1X,I0)', 'p20 z0,c2: ', loc(z0) - loc(c1), loc(c2) - loc(c1)
> end program
> ```
For `p20`, flang outputs `0 1` before the fix and `1 1` with the fix in the PR. It seems reasonable in the scope of this PR in the sense that no alignment for the zero-sized variable and natural alignment for `character(1)` variables.
**Ref outputs (all by default):**
- gfortran: `8 8`
- ifx/ifort: `1 1` (it outputs 4 4 or 8 8 if -align commons or -align dcommons option is used.)
- IBM XLF: `1 1`
https://github.com/llvm/llvm-project/pull/214174
More information about the flang-commits
mailing list