[Bug fortran/61069] Gfortran allows functions to be called as subroutines when defined in a separate source file

tristanmoody at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue May 6 18:53:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61069

--- Comment #9 from Tristan Moody <tristanmoody at gmail dot com> ---
(In reply to Steve Kargl from comment #8)
>   program foo
>   integer i
>   external bar, baz
>   i=0
>   call bar(i)
>   call baz(i)
>   end
> 
> This is standard conforming Fortran.  When gfortran compiles 
> this code, there is no way for gfortran to know that bar
> or baz is not a subroutine.  In fact, bar and baz may not have
> been written when the main program is compiled.  It is the
> programmer's responsibility to get the semantics right.

That *program unit* is, by itself, standard conforming.  The program as a whole
is not.  You are correct that it is incumbent upon the programmer to get that
part right.  Clause 1.5 of the standard only specifies that the compiler verify
correctness at the program unit level.  The standard does not explicitly say
the compiler must verify correctness of the code at a holistic level.  Thus,
whether gfortran will know whether bar or baz is a subroutine is irrelevant to
the question of whether the program is conforming.  They are two different
issues.

It is, in my opinion, a weakness of the language itself, as it allows names to
be introduced into global scope with no way to identify what they are.  That
said, the bug is closed "wontfix," which is fine with me, and I will stop
polluting everyone else's inboxes.



More information about the Gcc-bugs mailing list