[J3] Question abiout TARGET for dummy arguments
Van Snyder
van.snyder at sbcglobal.net
Fri Feb 23 22:49:21 UTC 2024
The characteristics of a dummy data object include whether it is
target. I assume that means whether it has the TARGET attribute, not
whether it actually appears as a target in a pointer-assignment
statement.
A procedure that I'm using has an explicit interface where it's
referenced. Part of that interface is an explicit interface for a dummy
procedure. An argument of the dummy procedure has the TARGET attribute
so that the actual procedure's argument can have it, just in case that
would be useful.
I have two programs that use that procedure. In one, pointer
association is used in the dummy procedure's effective actual
procedure, to give meaningful names to parts of the TARGET dummy
argument. In another one, an ASSOCIATE construct is used, so the TARGET
attribute is not necessary. But if I remove it in the actual procedure,
I can't compile the program.
Subclause 15.4.2.2 (F23) item (4)(a) says the interface has to be
explicit if a dummy argument has the TARGET attribute. Of course, it
can't say anything about the effect of an interface body lying about
whether an external procedure's dummy argument has (or does not have)
the TARGET attribute. 15.4.3.2p7 says the interface body shall specify
"consistent" characteristics but doesn't elaborate what that means.
Subclause 15.4.3.8 says that with implicit interface the actual
arguments shall be "consistent" with dummy arguments. There doesn't
appear to be a requirement in Subclause 15.5.2.5 that if the dummy
argument has the TARGET attribute, the actual argument also must have
it. Indeed, there are several paragraphs of discussion about what
happens if their "targetness" is different. So it's not clear why being
a target is a characteristic of a dummy argument, and why having the
TARGET attribute requires explicit interface. If the relationship of
the "targetness" of an actual argument that's not a dummy argument to
the "targetness" of the corresponding dummy argument doesn't matter,
why does it matter if the actual argument is also a dummy argument, but
apparently only in the case of a dummy procedure?
I assume the reason for the TARGET attribute in 1990 was to help
optimizers. The procedure that has the dummy procedure is actually a
Fortran 77 procedure that declares its dummy procedure EXTERNAL. All I
did was write an explicit interface for it. I lied about the actual
procedure's argument needing the TARGET attribute. If I make the
procedure interface EXTERNAL and implicit, or if I make the interface
for its procedure dummy EXTERNAL and implicit, the code compiles and
works no matter whether the actual procedure argument's argument has
the TARGET attribute, so whether the "targetness" agrees or not, in
particular whether an interface body for a F77 procedure lies about an
argument for its dummy procedure having (or not having) the TARGET
attribute, appears not to be required for the processors I've tried to
generate working code.
Is it really necessary for the "targetness" of an actual procedure's
argument to match the dummy procedure's argument?
Could we carve out an exception for the TARGET attribute in Subclause
15.2.10p1?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20240223/44baf34e/attachment.htm>
More information about the J3
mailing list