User account creation filtered due to spam.

Bug 37787 - right-left hand side overlap not recognized with EQUIVALENCEd array assignment
Summary: right-left hand side overlap not recognized with EQUIVALENCEd array assignment
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: wrong-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2008-10-09 20:15 UTC by Dick Hendrickson
Modified: 2008-10-19 07:51 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-10-12 10:49:12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dick Hendrickson 2008-10-09 20:15:55 UTC
The following program fails to recognize that the equivalence between qla1 and qla2 causes a dependency in the assignment.  Using qla1 on the right (ie resolving the dependency by hand) makes the problem go away.  It occurs for both explicit constant subscripts and variable subscripts.

Dick Hendrickson


! fails on Windows XP
! gcc version 4.4.0 20080603 (experimental) [trunk revision136333] (GCC)
!apparently, the EQUIVALENCE between QLA1 and QLA2 isn't recognized
!and the left-right overlap isn't recognized
      module stuff
      integer nf1, nf2
      integer, parameter :: r4_kv = 4
      contains

      SUBROUTINE CF0004
!  COPYRIGHT 1999   SPACKMAN & HENDRICKSON, INC.
!     CALL CF0004
      REAL(R4_KV) QLA1(100)
      REAL(R4_KV) QLA2(100)
      REAL(R4_KV) QLA3(100)
      REAL(R4_KV) QCA(100)
      EQUIVALENCE (QLA1, QLA2)

      do I = 1,100
      qca(i) = i
      enddo

      QLA1 = QCA
      QLA3 = QCA

      QLA3(  2:100:3) = QCA (  1:65:2) + 1
      QLA1(  2:100:3) = QLA2(  1:65:2) + 1            !fails
!      QLA1(NF2:100:3) = QLA2(NF1:65:2) + 1            !fails
!      QLA1(NF2:100:3) = QLA1(NF1:65:2) + 1            !works
!      QLA1(  2:100:3) = QLA1(  1:65:2) + 1            !works

      DO J1 = 1,100
      if (qla1(j1) .ne. qla3(j1)) print *, j1, qla1(j1), qla3(j1)
  100 ENDDO;

      END SUBROUTINE
      end module
      program try_cf004
      use stuff
      nf1 = 1
      nf2 = 2
      call cf0004
      end

C:\g_experiments\gfortran>gfortran cf0004_2.f

C:\g_experiments\gfortran>a
           8   5.0000000       6.0000000
          17   9.0000000       12.000000
          26  10.0000000       18.000000
          35   17.000000       24.000000
          44   21.000000       30.000000
          53   18.000000       36.000000
          62   29.000000       42.000000
          71   33.000000       48.000000
          80   19.000000       54.000000
          89   41.000000       60.000000
          98   45.000000       66.000000
Comment 1 Paul Thomas 2008-10-12 10:47:35 UTC
Subject: Bug 37787

Author: pault
Date: Sun Oct 12 10:46:14 2008
New Revision: 141073

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141073
Log:
2008-10-12  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/37787
	* dependency.c (gfc_are_equivalenced_arrays): Look in symbol
	namespace rather than current namespace, if it is available.

2008-10-12  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/37787
	* gfortran.dg/module_equivalence_5.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/module_equivalence_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/dependency.c
    trunk/gcc/testsuite/ChangeLog

Comment 2 Paul Thomas 2008-10-12 10:49:12 UTC
Since I fixed in on trunk already....

Thanks for the report.

Paul
Comment 3 Paul Thomas 2008-10-19 07:51:37 UTC
Fixed on trunk and 4.3
Comment 4 Paul Thomas 2008-10-19 07:52:00 UTC
Subject: Bug 37787

Author: pault
Date: Sun Oct 19 07:50:35 2008
New Revision: 141219

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141219
Log:
2008-10-19  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/37787
        * dependency.c (gfc_are_equivalenced_arrays): Look in symbol
        namespace rather than current namespace, if it is available.

2008-10-19  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/37787
        * gfortran.dg/module_equivalence_5.f90: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/module_equivalence_5.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/dependency.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog