[patch, fortran] Function call optimization

Steve Kargl sgk@troutmask.apl.washington.edu
Tue Mar 15 18:02:00 GMT 2011


On Tue, Mar 15, 2011 at 12:38:58PM -0500, jimmie.davis@l-3com.com wrote:
> 
>  
> ?$B"M AFAIK, this is permitted by the Fortran standard because such functions have side effects, the program is illegal.
> 
> How about something like this ?
> 
>          FUNCTION FOO (I)
>          COMMON /A,B,C/
>          A = A + I
>          FOO =  C+I
>          RETURN
> 
> The only time I can see this is safe is if it was restricted
> to PURE procedures.
> 
> Or maybe I am missing something :)
> 

I had essentially the same reaction, but haven't had
time to check the standard.  I suspect that you are
correct that this optimization can only be applied to
pure (and elemental) procedures.

-- 
Steve



More information about the Fortran mailing list