Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 35662
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Jakub Jelinek <jakub@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Kevin McCarty <kmccarty@debian.org>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 35662 depends on: Show dependency tree
Show dependency graph
Bug 35662 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2008-04-15 11:20 Opened: 2008-03-21 23:57
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

------- Comment #1 From Jakub Jelinek 2008-04-15 11:20 -------
This is a fortran FE bug.

------- Comment #2 From Jakub Jelinek 2008-04-16 15:57 -------
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

------- Comment #3 From Jakub Jelinek 2008-04-16 16:06 -------
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

------- Comment #4 From Jakub Jelinek 2008-04-16 16:11 -------
Fixed.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug