g77 bug report
Jan van Eldik
Jan.van.Eldik@cern.ch
Tue Nov 2 04:34:00 GMT 1999
Dear all,
I think I have found a bug in g77, versions 0.5.24 and 0.5.25. It
manifests itself in the program I list below, when I use compiler
options "-fno-automatic" and "-O1". The combination of these two
options gives wrong results. When I remove "-fno-automatic", or
change the optimization level to 0, 2 or 3, I get the proper result.
Addition of "-ffloat-store" also gives the correct result.
This is what I did:
lxp03 [93] g77 -W -Wall -O -fno-automatic -O1 g77_bug1.f
lxp03 [94] a.out
102. 13. 3. 153. 21. 231. 35. 6. 55. 13. 226. 33. 343. 69. 507.
lxp03 [95] g77 -W -Wall -O -fno-automatic -O2 g77_bug1.f
lxp03 [96] a.out
102. 13. 3. 153. 21. 231. 29. 6. 46. 10. 226. 33. 343. 69. 507.
lxp03 [97] g77 -W -Wall -O -O1 g77_bug1.f
lxp03 [98] a.out
102. 13. 3. 153. 21. 231. 29. 6. 46. 10. 226. 33. 343. 69. 507.
lxp03 [99] g77 -W -Wall -O -fno-automatic -O1 -ffloat-store g77_bug1.f
lxp03 [100] a.out
102. 13. 3. 153. 21. 231. 29. 6. 46. 10. 226. 33. 343. 69. 507.
where the first try gives the wrong result.
Here come the source code of a simple matrix manipulation, where the
resulting array overwrites the input array:
PROGRAM ETTEST
*
IMPLICIT NONE
REAL DERA(3,5), POIA(15)
DATA DERA / 1.0, 2.0, 3.0, 4.0, 5.0,
& 1.0, 2.0, 3.0, 4.0, 5.0,
& 1.0, 2.0, 3.0, 4.0, 5.0 /
DATA POIA / 5.0, 4.0, 3.0, 2.0, 1.0,
& 5.0, 4.0, 3.0, 2.0, 1.0,
& 5.0, 4.0, 3.0, 2.0, 1.0 /
CALL ETMUMA(DERA,POIA,POIA)
WRITE(*,*) POIA
END
SUBROUTINE ETMUMA(DER,WGTI,WGTO)
* Calcul le produit WGTO = DER(trans)*WGTI*DER
* Cas ou on a toujours DER(4,I)=delta(4,I), DER(5,I)=delta(5,I)
* DER(I,2)=delta(I,2) et DER(1,4)=DER(3,4)=0.
IMPLICIT NONE
REAL WGTI(15), WGTO(15), DER(3,5)
REAL W11, W13, W14, W15, W21, W22, W23, W24, W25, W31
REAL W33, W34, W35, W41, W43, W44, W51, W53, W54, W55
*
W11 = WGTI( 1)*DER(1,1) + WGTI( 2)*DER(2,1) + WGTI( 4)*DER(3,1)
CCC W12 = WGTI( 2)
W13 = WGTI( 1)*DER(1,3) + WGTI( 2)*DER(2,3) + WGTI( 4)*DER(3,3)
W14 = WGTI( 2)*DER(2,4) + WGTI( 7)
W15 = WGTI( 1)*DER(1,5) + WGTI( 2)*DER(2,5)
+ + WGTI( 4)*DER(3,5) + WGTI(11)
W21 = WGTI( 2)*DER(1,1) + WGTI( 3)*DER(2,1) + WGTI( 5)*DER(3,1)
W22 = WGTI( 3)
W23 = WGTI( 2)*DER(1,3) + WGTI( 3)*DER(2,3) + WGTI( 5)*DER(3,3)
W24 = WGTI( 3)*DER(2,4) + WGTI( 8)
W25 = WGTI( 2)*DER(1,5) + WGTI( 3)*DER(2,5)
+ + WGTI( 5)*DER(3,5) + WGTI(12)
W31 = WGTI( 4)*DER(1,1) + WGTI( 5)*DER(2,1) + WGTI( 6)*DER(3,1)
CCC W32 = WGTI( 5)
W33 = WGTI( 4)*DER(1,3) + WGTI( 5)*DER(2,3) + WGTI( 6)*DER(3,3)
W34 = WGTI( 5)*DER(2,4) + WGTI( 9)
W35 = WGTI( 4)*DER(1,5) + WGTI( 5)*DER(2,5)
+ + WGTI( 6)*DER(3,5) + WGTI(13)
W41 = WGTI( 7)*DER(1,1) + WGTI( 8)*DER(2,1) + WGTI( 9)*DER(3,1)
CCC W42 = WGTI( 8)
W43 = WGTI( 7)*DER(1,3) + WGTI( 8)*DER(2,3) + WGTI( 9)*DER(3,3)
W44 = WGTI( 8)*DER(2,4) + WGTI(10)
CCC W45 = WGTI( 7)*DER(1,5) + WGTI( 8)*DER(2,5)
CCC + + WGTI( 9)*DER(3,5) + WGTI(14)
W51 = WGTI(11)*DER(1,1) + WGTI(12)*DER(2,1) + WGTI(13)*DER(3,1)
CCC W52 = WGTI(12)
W53 = WGTI(11)*DER(1,3) + WGTI(12)*DER(2,3) + WGTI(13)*DER(3,3)
W54 = WGTI(12)*DER(2,4) + WGTI(14)
W55 = WGTI(11)*DER(1,5) + WGTI(12)*DER(2,5)
+ + WGTI(13)*DER(3,5) + WGTI(15)
*
WGTO( 1) = DER(1,1)*W11 + DER(2,1)*W21 + DER(3,1)*W31
WGTO( 2) = W21
WGTO( 3) = W22
WGTO( 4) = DER(1,3)*W11 + DER(2,3)*W21 + DER(3,3)*W31
WGTO( 4) = DER(1,3)*W11 + DER(2,3)*W21 + DER(3,3)*W31
WGTO( 5) = W23
WGTO( 6) = DER(1,3)*W13 + DER(2,3)*W23 + DER(3,3)*W33
WGTO( 7) = DER(2,4)*W21 + W41
WGTO( 8) = W24
WGTO( 9) = DER(2,4)*W23 + W43
WGTO(10) = DER(2,4)*W24 + W44
WGTO(11) = DER(1,5)*W11 + DER(2,5)*W21 + DER(3,5)*W31 + W51
WGTO(12) = W25
WGTO(13) = DER(1,5)*W13 + DER(2,5)*W23 + DER(3,5)*W33 + W53
WGTO(14) = DER(1,5)*W14 + DER(2,5)*W24 + DER(3,5)*W34 + W54
WGTO(15) = DER(1,5)*W15 + DER(2,5)*W25 + DER(3,5)*W35 + W55
END
Here comes the g77 version:
lxp03 [101] g77 -v
g77 version egcs-2.91.66 19990314 (egcs-1.1.2 release) (from FSF-g77
version 0.5.24-19981002)
Driving: /usr/local/bin/g77 -v -c -xf77-version /dev/null -xnone
Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/cpp -lang-c -v
-undef -D__GNUC__=2 -D__GNUC_MINOR__=91 -D__ELF__ -D__unix__
-D__i386__ -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux
-Asystem(posix) -D_LANGUAGE_FORTRAN -traditional -Asystem(unix)
-Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686
-Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__
/dev/null /dev/null
GNU CPP version egcs-2.91.66 19990314 (egcs-1.1.2 release) (i386
Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/i686-pc-linux-gnu/include
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/f771
-fnull-version -quiet -dumpbase g77-version.f -version -fversion -o
/tmp/cce5u4YI.s /dev/null
GNU F77 version egcs-2.91.66 19990314 (egcs-1.1.2 release)
(i686-pc-linux-gnu) compiled by GNU C version egcs-2.91.66 19990314
(egcs-1.1.2 release).
GNU Fortran Front End version 0.5.24-19981002
as -V -Qy -o /tmp/ccOAiOFi.o /tmp/cce5u4YI.s
GNU assembler version 2.9.1 (i386-redhat-linux), using BFD version
2.9.1.0.23
ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o /tmp/ccoaOLkT
/tmp/ccOAiOFi.o /usr/lib/crt1.o /usr/lib/crti.o
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/crtbegin.o
-L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66
-L/usr/local/i686-pc-linux-gnu/lib -L/usr/local/lib -lg2c -lm -lgcc
-lc -lgcc
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/crtend.o
/usr/lib/crtn.o
/tmp/ccoaOLkT
__G77_LIBF77_VERSION__: 0.5.24
@(#)LIBF77 VERSION 19970919
__G77_LIBI77_VERSION__: 0.5.24-19981021
@(#) LIBI77 VERSION pjw,dmg-mods 19980617
__G77_LIBU77_VERSION__: 0.5.24-19990305
@(#) LIBU77 VERSION 19980709
I hope this is enough information, and I also hope that I am reporting
a genuine problem...
regards, Jan van Eldik
More information about the Gcc-bugs
mailing list