Functions returning pointers
Paul Brook
paul@codesourcery.com
Mon Aug 23 11:33:00 GMT 2004
On Monday 23 August 2004 12:24, Tobias Schlüter wrote:
> Turning on optimization changed that. Consider:
> character*5, target :: c,e
> c = "Hallo"
> e = g()
>
> print *,e
> contains
> function g()
> character(5), pointer :: g
> g => c
> end function g
> end
>
> The function g gets compiled to this:
> (t03.original)
> g (__result, .__result)
> {
> __result = (int1[1 .. 5] * &)&c;
>
> Apparently, this statement only looks meaningful, the function is
> "optimized" to: (t59.optimized)
> ;; Function g (g.435)
>
> g (__result, .__result)
> {
> int1 * c.2;
>
> <bb 0>:
> return;
>
> }
> I.e. the compiler decides that the statement has no effect. Maybe it should
> be *__result = ... in the original dump?
Yes, that makes sense.
I forgot to mention that pointers to character variables may already be broken
in ways not related to your patch :-\
Paul
More information about the Fortran
mailing list