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
--
Summary: right-left hand side overlap not recognized with
EQUIVALENCEd array assignment
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dick dot hendrickson at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37787