This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/60777] New: Fortran 2003: RECURSIVE function rejected in specification expression
- From: "vladimir.fuka at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 07 Apr 2014 14:22:18 +0000
- Subject: [Bug fortran/60777] New: Fortran 2003: RECURSIVE function rejected in specification expression
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60777
Bug ID: 60777
Summary: Fortran 2003: RECURSIVE function rejected in
specification expression
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: vladimir.fuka at gmail dot com
John Harper reports on comp.lang.fortran:
! A recursive function in a specification expression
module recur
implicit none
contains
pure recursive function f(n) result(answer)
integer,intent(in) :: n
integer :: answer
if (n<2) then
answer = 1
else
answer = f(n-1)*n
end if
end function f ! factorial of max(n,0)
pure function usef( n)
integer,intent(in):: n
character(f(n)) :: usef
usef = repeat('*',f(n))
end function usef
end module recur
program testspecexpr
use recur
implicit none
integer :: n
do n = 1,3
print *,usef(n)
end do
end program testspecexpr
Which gives gfortran-4.9 resspec.f90
resspec.f90:18.16:
character(f(n)) :: usef
1
Error: Specification function 'f' at (1) cannot be RECURSIVE
but Fortran 2003 and 2008 just require:
7.1.11.6 (F2008): Evaluation of a specification expression shall not directly
or indirectly cause a procedure defined by the subprogram in which it appears
to be invoked.