Hi,

On Debian's mips and mipsel ports, gfortran 4.3 at -O1 or higher generates
object code that calls the sincosf() function in glibc's libm.  Unfortunately
the function call does not produce the correct result: it returns 0 for the
sine and 1 for the cosine.  Since an equivalent C program that uses sincosf()
does yield the right results, I conclude that it is gfortran and not libm where
the bug occurs -- somehow the call to sincosf() in the generated object code is
wrong.  (Not being too knowledgeable on either MIPS or assembly, I
unfortunately can't tell you why.  An erroneous assumption about the byte size
of the sine and cosine values returned by sincosf(), perhaps?)

This is a regression from gfortran 4.2.3, but the reason is apparently that
previous gfortran versions do not generate calls to sincosf().

Version information:

(sid)[EMAIL PROTECTED]:~$ gfortran-4.3 -v
Using built-in specs.
Target: mips-linux-gnu
Configured with: ../src/configure linux gnu
Thread model: posix
gcc version 4.3.1 20080309 (prerelease) (Debian 4.3.0-1)

Test case is at
http://people.debian.org/~kmccarty/gfortran-sincos-err-mips.tar.gz

The FORTRAN code is "sincos.F", and equivalent C code (I translated the FORTRAN
to C by hand) that explicitly uses sincosf() is "sincos.c".

The bad object code is located in subdirectories obj-fail/-O1 and obj-fail/-O2
of the tarball.  Correct object code generated at -O0 is in obj-success/-O0,
but may not be that useful for comparison, as the generated assembly with no
optimization calls the sinf() and cosf() functions individually.  Output of the
FORTRAN and C programs are in "output.txt" and "coutput.txt", respectively, in
each subdirectory.

You can quickly regenerate these files with "make output".

best regards,
Kevin McCarty


-- 
           Summary: [4.3 regression] gfortran interfaces badly with glibc
                    sincosf() causing breakage
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kmccarty at debian dot org
 GCC build triplet: mips-linux-gnu
  GCC host triplet: mips-linux-gnu
GCC target triplet: mips-linux-gnu


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

Reply via email to