This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Probable g77 compiler bug


!
!Dear g77 people,
!
!Following code fragment illustrates a compiler bug under RedHat7(.1?).
!Code works if print statments are included (see below), or -O3 and -fno-automatic
!are NOT on the command-line.  Otherwise it fails (see below).
!
!System details are :
!
!uname -a :Linux kereru 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown
!Hardware :Dell Optiplex, pentium 3.
!g77 -v   :See bottom of message for full text
!          __G77_LIBF77_VERSION__: 0.5.26 20000731 (prerelease)
!          @(#)LIBF77 VERSION 19991115
!          __G77_LIBI77_VERSION__: 0.5.26 20000731 (prerelease)
!          @(#) LIBI77 VERSION pjw,dmg-mods 19991115
!          __G77_LIBU77_VERSION__: 0.5.26 20000731 (prerelease)
!          @(#) LIBU77 VERSION 19980709
!gcc -v   :Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
!          gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81)
!
!If you need more info. please Email me J.Ravens@gns.cri.nz
!
!many thanks.

        program test

        implicit none
        integer*4 nsamps, isamp
        real*4  trace(36) / 
     -        17.6,  -1.6, -2.9, -3.9, -8.2, -10.4, -2.1, 11.0,
     -        15.0,  -0.2, -2.5, -3.8, -10.7, -11.3, -0.3, 14.2,
     -        20.4,  -1.7, -2.5, -3.7, -9.8, -14.1, -4.5, 12.8,
     -        22.7,  20.5, -1.4, -0.8, -2.28,  -9.9,-15.0, -5.5,
     -        -5.8,  12.1, 23.0, 21.6 /

        isamp=23                ! Start of search
        nsamps=36
        call nearest_minima (trace, isamp,nsamps)
        print*,'isamp=',isamp   ! should be 22
        end

! If compiled with -O3 or -fno-automatic, isamp=23 (wrong)
! else                                    isamp=22 (correct)
!
! If print statement at line 50 is commented out, isamp=23 (wrong)
! If   "       "      "  "   "  is active, isamp=22 (works)
!
! f77 -o nm nm.f;./nm
! f77 -o nm [-O3 -fno-automatic] nm.f;./nm


***************************************************************************

        subroutine nearest_minima (trace,isamp,nsamps)

        implicit none
        real*4      trace(*)
        integer*4   isamp, nsamps

        integer*4   left_is, right_is

        left_is  = isamp
        right_is = isamp

        do while (left_is.gt.2)
            left_is = left_is - 1
            if (trace(left_is).lt.trace(left_is-1) .and.
     -          trace(left_is).lt.trace(left_is+1)) goto 333
        end do
333     continue

        do while (right_is.lt.nsamps-1)
            right_is = right_is + 1
C            print*, '> right_is=',right_is
            if (trace(right_is).lt.trace(right_is-1) .and.
     -          trace(right_is).lt.trace(right_is+1)) goto 444
        end do
444     continue

        if (isamp-left_is .eq. right_is-isamp) then
            if (trace(left_is) .gt. trace(right_is)) then
                isamp = left_is
            else
                isamp = right_is
            end if
        else if (isamp-left_is .gt. right_is-isamp) then
            isamp = right_is
        else
            isamp = left_is
        end if
        return
        end

Full output of g77 -v :


g77 version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) (from FSF-g77 version 0.5.26 20000731 (Red Hat Linux 7.1 2.96-81))
Driving: g77 -v -c -xf77-version /dev/null -xnone
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81)
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/tradcpp0 -lang-fortran -v -D__GNUC__=2 -D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__tune_i386__ /dev/null /dev/null
GNU traditional CPP version 2.96 20000731 (Red Hat Linux 7.1 2.96-81)
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/f771 -fnull-version -quiet -dumpbase g77-version.f -version -fversion -o /work/tmp/ccWW0fzt.s /dev/null
GNU F77 version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) (i386-redhat-linux) compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.1 2.96-81).
GNU Fortran Front End version 0.5.26 20000731 (Red Hat Linux 7.1 2.96-81)
 as -V -Qy -o /work/tmp/ccimmgwO.o /work/tmp/ccWW0fzt.s
GNU assembler version 2.10.91 (i386-redhat-linux) using BFD version 2.10.91.0.2
 ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o /work/tmp/ccgHD278 /work/tmp/ccimmgwO.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crti.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/crtbegin.o -L/usr/lib/gcc-lib/i386-redhat-linux/2.96 -L/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../.. -lg2c -lm -lgcc -lc -lgcc /usr/lib/gcc-lib/i386-redhat-linux/2.96/crtend.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crtn.o
 /work/tmp/ccgHD278
__G77_LIBF77_VERSION__: 0.5.26 20000731 (prerelease)
@(#)LIBF77 VERSION 19991115
__G77_LIBI77_VERSION__: 0.5.26 20000731 (prerelease)
@(#) LIBI77 VERSION pjw,dmg-mods 19991115
__G77_LIBU77_VERSION__: 0.5.26 20000731 (prerelease)
@(#) LIBU77 VERSION 19980709


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]