Skip to content

[flang] Incorrect COMMON block storage sequence #142488

Closed
@DanielCChen

Description

@DanielCChen

Consider the following code:

   INTEGER i,j,k

   INTEGER i7(10)
   INTEGER i8(10)
   INTEGER i9(20)

   COMMON /BLOCK1/ i7,i8
   EQUIVALENCE (i7,i9)


   DO i = 1,20
      i9(i) = i
   END DO

   FORALL ( i = 1:10 )
      i8(i) = i9(9+i)
   END FORALL
   PRINT *,i8
   PRINT *,i9

END

Expected output:

 10 10 10 10 10 10 10 10 10 10
 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 10

Flang outputs:

 10 11 12 13 14 15 16 17 18 19
 1 2 3 4 5 6 7 8 9 10 10 11 12 13 14 15 16 17 18 19

The standard requires the storage sequence of a COMMON block to be the order of its object list.

The order of the storage sequences is the same as the order of the appearance of the common block object lists in the scoping unit.

Therefore, the assignment to i8 in FORALL should affect both i8 and i9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    flang:frontendquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions