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]

Is the included code standard conforming?


>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 to test intrinsic functions as actual arguments
subroutine test_r(fn, val, res)
  real fn
  real val, res

  if (diff(fn(val), res)) call abort
contains
function diff(a, b)
  real a, b
  logical diff
  diff = (abs(a - b) .gt. 0.00001)
end function
end subroutine

subroutine test_d(fn, val, res)
  double precision fn
  double precision val, res

  if (diff(fn(val), res)) call abort
contains
function diff(a, b)
  double precision a, b
  logical diff
  diff = (abs(a - b) .gt. 0.00001d0)
end function
end subroutine

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

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

TIA

Dominique


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