Skip to content

[Flang] Static initialization failure when the constant-expr is an array of derived type. #123362

@DanielCChen

Description

@DanielCChen

Consider the following code:

  PROGRAM  main
  IMPLICIT NONE

  TYPE :: DT
    CHARACTER(38) :: C = "1234567890abcdefghijklmnopqrstuvwxyz  "
    CHARACTER(16) :: C1= "543210  abc ABC "
  END TYPE

  TYPE (DT), PARAMETER :: X(4,4) = DT()
  !TYPE (DT), PARAMETER :: X = DT()      !! Works fine.

  INTEGER(KIND(VERIFY(STRING=X%C, SET=X%C1, KIND=1))) :: &
     &TI1(4,4)=VERIFY(STRING=X%C, SET=X%C1, KIND=1)
end

Flang currently failed to compile the above code as

error: Semantic errors in a4.f
./a4.f:13:16: error: Must be a constant value
       &TI1(4,4)=VERIFY(STRING=X%C, SET=X%C1, KIND=1)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The code seems standard conforming. All ifort, gfortran and XLF compile the code successfully. If X is scalar instead of an array, Flang compiles it fine.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions