Skip to content

[Flang] Incorrect diagnosis in structure constructor for array component #88747

@DanielCChen

Description

@DanielCChen

Consider the following test case

use, intrinsic :: iso_c_binding
type dt
  type(c_ptr) :: a(5)
end type
integer, target :: k
type(dt) :: x
x = dt(c_loc(k))
end

Flang currently issues an error as:

./t.f:7:8: error: Scalar value cannot be expanded to shape of array component 'a'
  x = dt(c_loc(k))
         ^^^^^^^^
./t.f:3:16: Declaration of 'a'
  type(c_ptr) :: a(5)
                 ^

It compiles the code fine if the type of a is intrinsic type as well as the corresponding argument to the structure constructor.
XLF, ifort and gfortran all accept the above code.

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorflang:frontend

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions