Possible bug in egcs-1.1.2-g77

Rafal Podeszwa poszwa@tiger.chem.uw.edu.pl
Thu Nov 18 03:49:00 GMT 1999


The following Fortran code that is supposed to extract 1 byte parts 
from 4 byte integer seems to produce a wrong code when using
g77 version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (from FSF-g77
version 0.5.24-19981002)

---BEGIN----test.f  
 program test
        integer*4 number,b1,b2,b3,b4,i
        number = 4*256*256*256+43*256*256+165*256+211

        do i=1,1
          call conversion(number,b1,b2,b3,b4)
          write(*,*)b1,b2,b3,b4
        end do

        end

        subroutine conversion(number,b1,b2,b3,b4)

        integer*4 number,b1,b2,b3,b4,x,y
        character*1 u(4),v(4)
        equivalence (x,u(1)),(y,v(1))

        x=number
        v(1)=u(1)
        b1=y
        v(1)=u(2)
        b2=y
        v(1)=u(3)
        b3=y
        v(1)=u(4)
        b4=y
        return
        end

---END----test.f

The program was compiled without any optimization and other compiler
options. I checked the source code with ftncheck and got no errors nor
warnings.  

The result on Pentium II 266 with Linux kernel 2.2.5 and glibc 2.1.1 was
 1073822675 1073822629 1073822507 1073822468
instead of 
211 165 43 4

When compiled by g77 with egcs-2.90.29 980515 (egcs-1.0.3
release) the program gives the proper result. 

Regards,

Rafal Podeszwa




More information about the Gcc-bugs mailing list