How to express the fact that arguments don't escape?

Richard Guenther richard.guenther@gmail.com
Sat Aug 15 11:54:00 GMT 2009


On Sat, Aug 15, 2009 at 1:32 PM, N.M. Maclaren<nmm1@cam.ac.uk> wrote:
> On Aug 15 2009, Richard Guenther wrote:
>>
>> It's of course one area where the Fortran choice of passing everything by
>> reference pessimizes it quite a bit compared to other frontends ...
>
> Can the back-end distinguish traditional call by reference (as in Algol 60
> and 68) from call by pointer value (and in C and C++)?  The former does

No it can't.  Well - the backend has the DECL_BY_REFERENCE, but it's
semantics are poorly documented.  Note that Fortran overly uses that
predicate anyway - likely because it is also used for debug information
annotation IIRC.

> not have the same pessimisation problem, and is actually what Fortran needs
> for 'ordinary' objects.
>
> The difference could be useful for the C++ STL and possibly Ada, but I have
> forgotten the little of the latter that I once knew and so am not sure.

I don't think so.  You can take the address of even passed by value objects in
C++ if you make sure to remove all references in the destructor that runs after
the call completes.  See some previous bugs we had in this area.

Richard.



More information about the Fortran mailing list