Skip to content

A restricted expression may contain object designators whose base object is a dummy with INTENT(OUT) when they occur in specification inquiries #1599

@rofirrim

Description

@rofirrim

(Sorry again for the wordy title)

flang is rejecting the following code

module my_mod

contains
  subroutine my_sub(str)
    implicit none
    character(len=*), intent(out) :: str

    character(len=1,kind=1), dimension(1:len(str)+1), target :: array_of_char
  end subroutine my_sub

end module my_mod
error: Semantic errors in t.f90
./t.f90:8:65: error: Invalid specification expression: reference to INTENT(OUT) dummy argument 'str'
      character(len=1,kind=1), dimension(1:len(str)+1), target :: array_of_char
                                                                  ^^^^^^^^^^^^^

A quick read to C1010 (§10.1.11 in Fortran 2018 draft) suggests that this should be rejected due to 10.1.11p2 (2), so flang seems correct. However, all other compilers I've been able to test accept this.

Screenshot from 2022-05-02 11-44-51

If we keep reading, there is 10.1.11p2 (7)

Screenshot from 2022-05-02 11-45-39

"Specification inquiry" is defined at 10.1.11p4 and 10.1.11p4 (1) should cover the invocation to LEN.

Screenshot from 2022-05-02 11-49-02

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions