------- Comment #14 from burnus at gcc dot gnu dot org  2010-06-22 05:47 -------
> > Additionally allowed without temporary:
> >   sym->attr.dummy && sym->attr.intent == INTENT_OUT
> > as
> >  "If a dummy argument has INTENT (OUT), the actual argument becomes
> >   undefined at the time the association is established"
> > thus also any access via any method to that variable is undefined - and thus
> > invalid.
> >
> > I think that the LHS is a dummy argument is a very common case and thus it
> > makes sense to optimize for INTENT(OUT).
> 
> Hmmm!  I'll have to think about this business of dummies and their
> intent.  Perhaps you could give me an example, where this causes
> aliasing?

Example:

  real :: a(100)
  call test(a)
contains
  subroutine test(x)
    real, INTENT(OUT) :: x(:)
    x = f()
  end subroutine test

Here, no temporary is needed for "x = f()": The dummy "x" is INTENT(OUT) thus
the actual argument (i.e. "a") becomes undefined. Thus, the following function
is invalid as "a" is (also) undefined in "f":

  function f()
    real :: f(100)
    f = a
  end function f
end

I think that your patch will generate a temporary in this case - it shouldn't.
(Unfortunately, one cannot make similar assumptions for other intents :-(


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44582

Reply via email to