Overview Description: 
 A very simple TEST.F code using D1MACH.F from SLATEC (to initialize machine
constants) compiles correctly using GFORTRAN, but the produced executable gives
nonsense results.

Steps to Reproduce:
1. Save the following program TEST.F and the routine D1MACH.F

**************
      program test
      implicit none
      real(8) d1mach
      write(6,*)1,d1mach(1)
      write(6,*)2,d1mach(2)
      write(6,*)3,d1mach(3)
      write(6,*)4,d1mach(4)
      write(6,*)5,d1mach(5)
      stop
      end program test
**************
      DOUBLE PRECISION FUNCTION D1MACH (I)
C
      INTEGER SMALL(4)
      INTEGER LARGE(4)
      INTEGER RIGHT(4)
      INTEGER DIVER(4)
      INTEGER LOG10(4)
C
      DOUBLE PRECISION DMACH(5)
      SAVE DMACH

      EQUIVALENCE (DMACH(1),SMALL(1))
      EQUIVALENCE (DMACH(2),LARGE(1))
      EQUIVALENCE (DMACH(3),RIGHT(1))
      EQUIVALENCE (DMACH(4),DIVER(1))
      EQUIVALENCE (DMACH(5),LOG10(1))
C
C     MACHINE CONSTANTS FOR THE INTEL i860
C
      DATA DMACH(1) / Z'0010000000000000' /
      DATA DMACH(2) / Z'7FEFFFFFFFFFFFFF' /
      DATA DMACH(3) / Z'3CA0000000000000' /
      DATA DMACH(4) / Z'3CB0000000000000' /
      DATA DMACH(5) / Z'3FD34413509F79FF' /
C***FIRST EXECUTABLE STATEMENT  D1MACH
      D1MACH = DMACH(I)
      RETURN
C
      END
**************

2. Compile with the command 
       gfortran test.f d1mach.f -o test.exe

3. Run ./test.exe 


Actual results:
./test.exe
           1   4503599627370496.0     
           2  9.21886843722740531E+018
           3  4.36849163854938112E+018
           4  4.37299523817675162E+018
           5  4.59909449422310451E+018


Expected results:
./test.exe

 1 2.2250738585072014E-308
 2 1.7976931348623157E+308
 3 1.1102230246251565E-16
 4 2.220446049250313E-16
 5 0.3010299956639812

Build date and platform:
 Dec.05.2007, WinXP (cygwin environment)


Additional information:

1. gfortran --version
GNU Fortran (GCC) 4.3.0 20071017 (experimental) [trunk revision 129419]

2. gcc --version
gcc.exe (GCC) 4.3.0 20071017 (experimental) [trunk revision 129419]


-- 
           Summary: gfortran compiles SLATEC library, but the executable
                    fails
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fabio dot subba at polito dot it


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34345

Reply via email to