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)kmccarty@larsa:~$ 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
This is a fortran FE bug.
Subject: Bug 35662 Author: jakub Date: Wed Apr 16 15:56:58 2008 New Revision: 134349 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134349 Log: PR target/35662 * f95-lang.c (gfc_init_builtin_functions): Make sure BUILT_IN_SINCOS{,F,L} types aren't varargs. * gfortran.dg/pr35662.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/pr35662.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/f95-lang.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 35662 Author: jakub Date: Wed Apr 16 16:05:51 2008 New Revision: 134352 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134352 Log: PR target/35662 * f95-lang.c (gfc_init_builtin_functions): Make sure BUILT_IN_SINCOS{,F,L} types aren't varargs. * gfortran.dg/pr35662.f90: New test. Added: branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/pr35662.f90 Modified: branches/gcc-4_3-branch/gcc/fortran/ChangeLog branches/gcc-4_3-branch/gcc/fortran/f95-lang.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
Fixed.