[4.5, Patch, Fortran] PR 36704: Procedure pointer as function result
Tobias Burnus
burnus@net-b.de
Tue Dec 9 08:09:00 GMT 2008
Mikael,
> > See in the F2003 standard:
> > "13.6 Specific names for standard intrinsic functions"
> I understand this as: The type of the result matches
> that of the argument but said with a complicated
> and obfuscated sentence.
Well, it was seemingly late because it is saying
something different.
1. It allows
procptr => sin
and
call myproc(sin)
as it is not marked with a bullet. And
"sin" is here not a generic function(!) but
a specific function.
2. The table states:
Specific Name Generic Name Argument Type
SIN SIN default real
That is: If you use the specific name "SIN" it is
a function which takes as argument a default REAL
variable.
> As you can see, the sin_r4 specific is called,
> not the sin_r8 as I expected.
But how should the compiler know that you want to have
the sin_r8? In your case one could argue that it might
know but how for:
procedure(), pointer :: ptr; ptr => sin
or for
call some_external_proc(sin)
Here, it is not obvious. Thus the standard defines which
of the specific functions which belong to a generic function
is called. If you use "SIN" you get a default-real function
and if you use DSIN you get a double-precision function.
I think the compiler could print a warning/error for such
casts.
> But as Janus said procedure pointer interfaces are
> disabled/unimplemented for now.
I think they work - but the argument checking is disabled;
if it were enabled, it might have rejected your non standard
conforming program.
Tobias
More information about the Fortran
mailing list