This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/44582] gfortran generates wrong results due to wrong ABI in function with array return
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jun 2010 05:47:09 -0000
- Subject: [Bug fortran/44582] gfortran generates wrong results due to wrong ABI in function with array return
- References: <bug-44582-19345@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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