[Patch, fortran] PR38863 - WHERE with multiple elemental defined assignments gives wrong answer

Paul Richard Thomas paul.richard.thomas@gmail.com
Wed Feb 4 22:39:00 GMT 2009


This turned out to be a problem with over-conservative dependency
checking.  For the reasons explained in the attached testcase
comments, the redundant temporary caused the result to be different to
that obtained with other compilers.

A much reduced testcase is the following:

 integer :: x(10)
  call foo (x, 10)
contains
  subroutine foo (x, n10)
    integer :: n10
    integer :: x(n10)
    x = x (1:10)
  end subroutine
end

This produces a temporary without the patch because the full array ref
is not recognised to be the same as the explicit range because the
array is automatic.  Of course, the solution is easy - check that one
of the bounds and the stride is the same for the array and the
reference.

I have no feeling for whether or not this is such an extreme corner
case as to be useless.  However, the patch fixes the PR:-)

Bootstrapped and regtested on FC9/x86_64 - OK for 4.5?

Paul

2009-02-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38863
	* dependency.c (ref_same_as_full_array): New function.
	(gfc_dep_resolver): Call it.

2009-02-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38863
	* gfortran.dg/dependency_23.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit.diff
Type: application/octet-stream
Size: 4642 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090204/9a15144c/attachment.obj>


More information about the Gcc-patches mailing list