[Bug fortran/17987] New: multidimensional array problem
shil at hep dot physics dot mcgill dot ca
gcc-bugzilla@gcc.gnu.org
Thu Oct 14 02:24:00 GMT 2004
Dear GNU developers:
I find a bug in the GNU g77 compiler. But I do not know what the proper way to
report this bug is.
At least from your website, it did not say anything.
http://www.gnu.org/software/fortran/fortran.html
I think this bug might be a common problem and may affect anyone who uses GNU
g77 for scientific computation.
It does not properly handle multi-dimensional array, and overwrite the array
when the array is called twice.
Here is a sample code to show this bug:
write(*,*)'======1st time================='
r = 0.23
x1 = shap(r)
write(*,*)' '
write(*,*)'=======2nd time================'
r = 0.43
x1 = shap(r)
write(*,*)' '
end
FUNCTION SHAP(R)
PARAMETER (NIC=2,DR=1.0)
DIMENSION ZZZ(NIC,2,2)
C
C
LOGICAL FIRST
DATA FIRST/.TRUE./
C
IF(FIRST)THEN
write(*,*) ' '
write(*,*)'first time is=:'
DO 20 K=1,2
DO 30 IR = 1, NIC
ZZZ(IR,1,K)=IR*0.2
ZZZ(IR,2,K)=IR*1.0
write(*,*) IR,1,k,ZZZ(IR,1,k)
c ,' ',IR,2,k,ZZZ(IR,2,k)
30 continue
20 CONTINUE
FIRST=.FALSE.
ENDIF
C
X=R/DR
IR=X
IR = IR+1
SHAP=ZZZ(IR,1,1)
write(*,*)' '
write(*,*)'ZZZ are=:'
do ir = 1,NIC
write(*,*) IR,ZZZ(IR,1,1),ZZZ(IR,2,1)
c ,ZZZ(IR,1,2),ZZZ(IR,2,2)
enddo
write(*,*)' '
C
END
=================
here is the output after compiled with g77 and run
======1st time=================
first time is=:
1 1 1 0.200000003 1 2 1 1.
2 1 1 0.400000006 2 2 1 2.
1 1 2 0.200000003 1 2 2 1.
2 1 2 0.400000006 2 2 2 2.
ZZZ are=:
1 0.200000003 1. 0.200000003 1.
2 0.400000006 2. 0.400000006 2.
=======2nd time================
ZZZ are=:
1 4.01037576E-34 3.99528214E-34 0.200000003 1.
2 -1.99970341 1.40129846E-44 0.400000006 2.
The machine I tested is a linux machine with GNU compiler.
I do not know how to read the version number, but here is the output from version:
g77 version 2.95.4 20011002 (Debian prerelease) (from FSF-g77 version 0.5.25
20010319 (prerelease))
Driving: g77 -v -c -xf77-version /dev/null -xnone
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
/usr/lib/gcc-lib/i386-linux/2.95.4/cpp0 -lang-c -v -D__GNUC__=2
-D__GNUC_MINOR__=95 -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix
-D__linux -Asystem(posix) -D_LANGUAGE_FORTRAN -traditional -Acpu(i386)
-Amachine(i386) -Di386 -D__i386 -D__i386__ /dev/null /dev/null
GNU CPP version 2.95.4 20011002 (Debian prerelease) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc-lib/i386-linux/2.95.4/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3
/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../i386-linux/include
End of omitted list.
/usr/lib/gcc-lib/i386-linux/2.95.4/f771 -fnull-version -quiet -dumpbase
g77-version.f -version -fversion -o /tmp/ccHI4ihp.s /dev/null
GNU F77 version 2.95.4 20011002 (Debian prerelease) (i386-linux) compiled by GNU
C version 2.95.4 20011002 (Debian prerelease).
GNU Fortran Front End version 0.5.25 20010319 (prerelease)
as -V -Qy -o /tmp/cc6Q5cUG.o /tmp/ccHI4ihp.s
GNU assembler version 2.14.90.0.7 (i386-linux) using BFD version 2.14.90.0.7
20031029 Debian GNU/Linux
ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o /tmp/ccD1JxIY
/tmp/cc6Q5cUG.o /usr/lib/crt1.o /usr/lib/crti.o
/usr/lib/gcc-lib/i386-linux/2.95.4/crtbegin.o
-L/usr/lib/gcc-lib/i386-linux/2.95.4 -lg2c -lm -lgcc -lc -lgcc
/usr/lib/gcc-lib/i386-linux/2.95.4/crtend.o /usr/lib/crtn.o
/tmp/ccD1JxIY
__G77_LIBF77_VERSION__: 0.5.25 20010319 (prerelease)
@(#)LIBF77 VERSION 19990503
__G77_LIBI77_VERSION__: 0.5.25 20010319 (prerelease)
@(#) LIBI77 VERSION pjw,dmg-mods 19990503
__G77_LIBU77_VERSION__: 0.5.25 20010319 (prerelease)
@(#) LIBU77 VERSION 19980709
Please let me know if you can reproduce this bug.
Best,
--
Summary: multidimensional array problem
Product: gcc
Version: 2.95.4
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: shil at hep dot physics dot mcgill dot ca
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17987
More information about the Gcc-bugs
mailing list