Re: procedure argument



Roland Schmehl <rschmehl@xxxxxxxxx> wrote:

[invalid code]

why does it accept the EXTERNAL statements?

Because compilers are not required to diagnose all errors, specifically
including this one. The code is invalid, but that doesn't mean the
compiler will necessarily figure that out. Some compilers might diagnose
the error. Others might crash when trying to run it. Others might appear
to "work" for some definition of the term, which is what you observed.
This is the nature of invalid (well... nonstandard) code.

Implicit interfaces (which you have with the EXTERNAL statement) are
notorious for being prone to errors that are typically not detected by
compilers. This was a major source of program crashes in pre-f90 codes.
I advise using explicit interfaces in new code whenever practical (note
that having an explicit interface does not necessarily mean writing out
an interface body; module procedures and internal procedures always have
explicit interfaces). If you use implicit interfaces, you will have
increased odds of such undiagnosed errors. There are also other reasons
to use explicit interfaces, but I'll not go into that right now.

As to why a particular compiler does or does not disgnose the problem -
that's a question for the compiler writers. The answer will presumably
vary from one compiler to another. I can predict that the general gist
of the answer, for those compilers that don't diagnose it, is probably
along the general line of too much work for the benefit. A compiler does
generally have to go to a lot more work if it is to cross-check such
things when implicit interfaces are used.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.



Relevant Pages

  • Re: Proposal: NOEXTERNAL
    ... I wasn't aware that this aspect of explicit interfaces via modules was deemed to be not that important. ... I'm currently leaning towards a tool that generates the module file with the interface definitions pre-compilation. ... I prefer that approach than relying on a compiler doing it. ...
    (comp.lang.fortran)
  • Re: GFORTRAN PROBLEM WITH SAVE STATEMENT
    ... module end pulls error. ... specification statement. ... If you ever had a compiler that failed to diagnose this, ...
    (comp.lang.fortran)
  • Re: c_loc - error with gfortran, not ifort
    ... While this method has some advantages, a disadvantage is that there is nothing the compiler can "hook into" to diagnose such errors of usage. ... User communities for Intel Software Development Products ...
    (comp.lang.fortran)
  • Re: Are procedure dummy arguments ignored in generic procedure resolution?
    ... > if the compiler is required to diagnose them. ... > I/O statement to reference it. ... that are run-time expressions must also be diagnosable. ...
    (comp.lang.fortran)
  • Re: Unknown construction
    ... compiler be able to diagnose *ANY* errors. ... requires that the compiler be able to diagnose *ANY* errors, ... not all errors" and not "f90 is the first Fortran standard that requires ...
    (comp.lang.fortran)