https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109403

            Bug ID: 109403
           Summary: Alignment of common blocks not reported correctly
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jahns at dkrz dot de
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

When compiling a source file with -flto, the alignment of common blocks seems
to not be reported from gcc-nm:

$ cat >align-test.f90 <<EOF
      MODULE CONFTEST_ALIGN
      USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT
      IMPLICIT NONE
      INTEGER(C_INT), PUBLIC, &
        BIND(c, name='align_test_variable') :: align_test_variable
      END MODULE CONFTEST_ALIGN
EOF
$ gfortran -flto -O2 -c -o align-test.o align-test.f90
$ gcc-nm align-test.o
00000000 C align_test_variable

Expected value was 4 byte alignment, but any value other than 0 would be
acceptable as long as it matches what the resulting DSO or program later
contains.

I tested this initially with gfortran 11.1 and 11.2 on Linux x86_64 because
that's what I have readily available and what I'm most interested in.

An equivalent C source exhibits the same problem:
$ echo "int align_test_variable __attribute__((common));" \
  | gcc -c -flto -x c - -o align-test-c.o
$ gcc-nm align-test-c.o 
00000000 C align_test_variable

Since no one seems to have reported similar experiences I expect to still find
this problem in most recent compiler versions.

Reply via email to