https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127730
Bug ID: 127730
Summary: ASSOCIATE name lacks the TARGET attribute when the
selector is a pointer function reference
Product: gcc
Version: 16.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: ivan.pribec at gmail dot com
Target Milestone: ---
Created attachment 65749
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65749&action=edit
Self-checking test case: ASSOCIATE with a pointer function selector
The following code currently fails to compile, despite the selector f() being a
legal target:
program p
implicit none
real, target :: tgt(3) = [1., 2., 3.]
real, pointer :: ptr(:)
associate (a => f())
ptr => a ! Error: Pointer assignment target is
neither TARGET nor POINTER
print *, associated(ptr, a) ! Error: 'target' argument of 'associated'
intrinsic ... must be a POINTER or a TARGET
end associate
contains
function f() result(r)
real, pointer :: r(:)
r => tgt
end function
end program
The code is accepted by ifx and flang. A slightly extended example can be found
in the attachment.