Skip to content

[flang] Error when using constant expression as KIND= expression #161961

@DanielCChen

Description

@DanielCChen

Consider the following code

  type base(k1,k2)
      integer(1),kind :: k1
      integer(k1),kind :: k2
      integer(kind(int(k1,1)+int(k2,k1))),allocatable :: i(:) !! FAIL
      !integer(kind(int(k1,1)+int(k2,2))),allocatable :: i(:) !! WORK
   end type
   type(base(2,2)) :: b1
   print*, kind(b1%i)
   end

Flang complains:

./t.f:4:30: error: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
        integer(kind(int(k1,1)+int(k2,k1))),allocatable :: i(:) !! FAIL

If I replace k1 with 2, which is the same value when the type is instantiated, it works.

This is a similar issue to issue #161694

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions