Skip to content

[flang] Flang seems too restrictive on constant expression usage. #161694

@DanielCChen

Description

@DanielCChen

Consider the following code

    type A (p, r)
        integer, kind :: p, r
        real (selected_real_kind(p, r)) :: data
    end type
    type(a(6,23)) :: a1
    print*, a1%data%kind

end

Flang failed at the compile time with

error: Semantic errors in t.f
./t.f:3:15: error: Must be a constant value
          real (selected_real_kind(p, r)) :: data
                ^^^^^^^^^^^^^^^^^^^^^^^^

All ifort, gfortran and XLF compile and execute the code successfully.
The folding of selected_real_kind could occur when the type is instantiated.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions