This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Is the included code standard conforming?


Dominique Dhumieres wrote:
From the first sentence of

13.1 Classes of intrinsic procedures
...
If an intrinsic function is used as an actual argument to a procedure, its
specific name shall be used and it may be referenced in the called
procedure only with scalar arguments.  If an intrinsic function does not
have a specific name, it shall not be used as an actual argument
(12.4.1.3). ...

can I infer that the following code is not standard conforming?
[...]
program specifics

  intrinsic log
  intrinsic log10

  call test_r (log, 2.0, log(2.0))
  call test_r (log10, 2.0, log10(2.0))
  call test_d (log, 2.0d0, log(2.0d0))
  call test_d (log10, 2.0d0, log10(2.0d0))

end program

I would agree that this is not standard-conforming, yes.


Should this be detected with -std=f95? (yes I now understand that the "shall" is for the user and not for the compiler).

I believe that it should be detected and an error thrown, regardless of option.


Unless I am quite mistaken, it is essentially impossible for a compiler to generate correct code in this case, at least if the program and subroutines are compiled separately. The main program does not have an explicit interface for test_r and test_d, and so the compiler has no way of resolving the generic to a specific prior to passing it. However, when test_r and test_d are compiled, the compiler has no way of knowing whether or not the passed function needs to be resolved from a generic to a specific (nor, most likely, any mechanism for resolving it).

- Brooks


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]