https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78737

--- Comment #20 from janus at gcc dot gnu.org ---
(In reply to Damian Rouson from comment #19)
> > On thinking about it, is the specific instance of write_formatted allowed?
> 
> I believe not.  Note 7.50 of the 31 August 2016 draft Fortran 2015 standard
> includes the following:
> 
> "The dynamic type of an object cannot be abstract; therefore, a deferred
> type-bound procedure cannot be invoked."
> 
> I interpret the above quote to mean that write_formatted as written in
> comment #15 cannot be invoked.  Presumably that also means it is invalid
> code. 

I'm not so sure here. Actually I tend to believe that comment 15 as such is
valid. It just has two different things that (incidentally) share the same name
(which is not forbidden in this context):
1) The deferred TBP 'write_formatted' of the type 'object'. As it is deferred,
it has no implementation in that type and can only be invoked polymorphically.
2) The subroutine 'write_formatted' in the module 'object_interface'. I don't
see anything that would prevent you from defining a subroutine in this way, but
it simply cannot be interpreted as the implementation of the deferred TBP.

But then gfortran's runtime-interpretation of this code is wrong. It prints
(with Paul's patch)

 write_formatted =>   99
 write_formatted2 =>   99

since it calls 'write_formatted' as a DTIO procedure of the type 'object',
which it is not! I think the correct output would only consist of the second
line:

 write_formatted2 =>   99

Reply via email to