https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86679
Bug ID: 86679
Summary: invalid code involving TARGET attribute is not
rejected
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: janus at gcc dot gnu.org
Target Milestone: ---
Please consider this simple example:
program pgm
integer :: i = 0
print *, i
call modify(i)
print *, i
contains
subroutine modify(t)
integer, intent(in), target :: t
integer, pointer :: p
p => t
p = 5
end subroutine
end
I assume for now it is invalid, but haven't checked the standard yet. There are
two issues that I can see:
1) We are casting a pointer to a variable ('i') that is not declared as TARGET.
gfortran should probably check that in the subroutine call the TARGET
attributes of formal and actual argument match.
2) We are modifying an INTENT(IN) argument (via pointer indirection). I hope
that the combination of INTENT(IN) and TARGET might actually be forbidden in
the Fortran standard. If it is not, we probably need a runtime check which
detects this.