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: Obsolescent character function (Cygwin)


On Tue, Sep 12, 2006 at 01:03:15AM +0200, Angelo Graziosi wrote:
> 
> When I build the following simple test case 
> 
> program prova
>   implicit none
>   character(len = 10) :: chfun
>   write(*,*) chfun(5),chfun(25)
> end program prova
> 
> function chfun(x)
>   implicit none
>   integer :: x
>   character(len=*) :: chfun
>   write(chfun,'(I10)')  x
> end function chfun
> 
> with
> 
>    gfc prova.F95 -o prova
> 
> I have:
> 
>  In file prova.F95:8
> 
> function chfun(x)
>              1
> Warning: CHARACTER(*) function 'chfun' at (1) is obsolescent in fortran 95
> 
> Why is 'chfun' obsolescent ?
> 

>From the Fortran 95 standard (whether gfortran gets this right I
have investigated.)

B.2.5    Assumed character length functions

Assumed character length for functions is an irregularity in the language
since elsewhere in Fortran the philosophy is that the attributes of a
function result depend only on the actual arguments of the invocation and
on any data accessible by the function through host or use association.
Some uses of this facility can be replaced with an automatic character
length function, where the length of the function result is declared in
a specification expression.  Other uses can be replaced by the use of a
subroutine whose arguments correspond to the function result and the
function arguments.

Note that dummy arguments of a function may be assumed character length.

-- 
Steve


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