Skip to content

[Flang] Incorrect diagnostic on array constructor using intrinsic functions. #124191

@DanielCChen

Description

@DanielCChen

Consider the following code

character(3) :: arr(5)
  arr = [character(3):: 'aa.', 'bb.', 'cc.', 'dd.', 'ee.']
  print*, [integer:: (mod(iachar(arr(i:i-1:-1)(1:1)),5)+1, i=2,5,3)]
  print*, [character(3):: arr(5:2:-1)]
!  arr([4,3,2,1]) = &                                                            !! Same vector script as the line below.
  arr([integer:: (mod(iachar(arr(i:i-1:-1)(1:1)),5)+1, i=2,5,3)]) = &            !! Unexpected rror
   [character(3):: arr(5:2:-1)]
  print *, '10:', arr
end

Flang currently issues a compile time error as

./t.f:6:3: error: Dimension 1 of left-hand side has extent 2, but right-hand side has extent 4
    arr([integer:: (mod(iachar(arr(i:i-1:-1)(1:1)),5)+1, i=2,5,3)]) = &
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The vector subscript is [4,3,2,1] as indicated in the print statement. The error is in incorrect.
All ifort, gfortran and XLF compile and run the code successfully.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions