public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/33683]  New: calculating lgamma instead of gamma
@ 2007-10-06 22:23 tkoenig at gcc dot gnu dot org
  2007-10-06 22:28 ` [Bug libfortran/33683] " dominiq at lps dot ens dot fr
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-10-06 22:23 UTC (permalink / raw)
  To: gcc-bugs

$ cat g.f90 
program main
  real :: x
  x = 10.
  print *,gamma(x)
end program main
$ gfortran g.f90 
$ ./a.out
   12.801827    
$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../../gcc/trunk/configure --prefix=/home/ig25
--enable-languages=c,fortran --enable-mainainer-mode
Thread model: posix
gcc version 4.3.0 20071006 (experimental) (GCC)


-- 
           Summary: calculating lgamma instead of gamma
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: critical
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/33683] calculating lgamma instead of gamma
  2007-10-06 22:23 [Bug libfortran/33683] New: calculating lgamma instead of gamma tkoenig at gcc dot gnu dot org
@ 2007-10-06 22:28 ` dominiq at lps dot ens dot fr
  2007-10-06 23:04 ` fxcoudert at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-10-06 22:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dominiq at lps dot ens dot fr  2007-10-06 22:28 -------
On Darwin I get:

/usr/bin/ld: Undefined symbols:
_gammaf
collect2: ld returned 1 exit status

Target: powerpc-apple-darwin8
Configured with: ../gcc-4.3-work/configure --prefix=/opt/gcc/gcc4.3w
--mandir=/opt/gcc/gcc4.3w/share/man --infodir=/opt/gcc/gcc4.3w/share/info
--build=powerpc-apple-darwin8 --enable-languages=c,fortran --with-gmp=/sw
--with-libiconv-prefix=/sw --with-system-zlib --x-includes=/usr/X11R6/include
--x-libraries=/usr/X11R6/lib
Thread model: posix
gcc version 4.3.0 20071006 (experimental) (GCC) 

revision 129055.


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/33683] calculating lgamma instead of gamma
  2007-10-06 22:23 [Bug libfortran/33683] New: calculating lgamma instead of gamma tkoenig at gcc dot gnu dot org
  2007-10-06 22:28 ` [Bug libfortran/33683] " dominiq at lps dot ens dot fr
@ 2007-10-06 23:04 ` fxcoudert at gcc dot gnu dot org
  2007-10-07 10:22 ` tkoenig at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-10-06 23:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2007-10-06 23:04 -------
I checked and the simplification routines work correctly, which means there is
no real testsuite coverage for these functions. We should always include
testcases comparing values calculated at runtime with constants coming from our
simplification routines.


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/33683] calculating lgamma instead of gamma
  2007-10-06 22:23 [Bug libfortran/33683] New: calculating lgamma instead of gamma tkoenig at gcc dot gnu dot org
  2007-10-06 22:28 ` [Bug libfortran/33683] " dominiq at lps dot ens dot fr
  2007-10-06 23:04 ` fxcoudert at gcc dot gnu dot org
@ 2007-10-07 10:22 ` tkoenig at gcc dot gnu dot org
  2007-10-07 12:02 ` tobi at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-10-07 10:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from tkoenig at gcc dot gnu dot org  2007-10-07 10:22 -------
(In reply to comment #2)
> I checked and the simplification routines work correctly, which means there is
> no real testsuite coverage for these functions. We should always include
> testcases comparing values calculated at runtime with constants coming from our
> simplification routines.

I concur.  PR 22307 strikes again...

The cause of the problem is outlined in the gamma(3) man page
of my Linux distro:

DESCRIPTION
       For the definition of the Gamma function, see tgamma(3).

   *BSD version
       4.4BSD and FreeBSD libm have a gamma() function that computes the Gamma
       function, as one would expect.

   glibc version
       Glibc has a gamma() function that is equivalent to  lgamma()  and  com-
       putes  the  natural logarithm of the Gamma function.  (This is for com-
       patibility reasons only.  Don't use this function.)

CONFORMING TO
       4.2BSD.  Compatible with previous mistakes.

I think we need to use tgamma() where available.  If it isn't, we
need a test to check whether gamma() is equivalent to tgamma() or
to lgamma().

Yuck.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-10-07 10:22:12
               date|                            |


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/33683] calculating lgamma instead of gamma
  2007-10-06 22:23 [Bug libfortran/33683] New: calculating lgamma instead of gamma tkoenig at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-10-07 10:22 ` tkoenig at gcc dot gnu dot org
@ 2007-10-07 12:02 ` tobi at gcc dot gnu dot org
  2007-10-07 16:48 ` tkoenig at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-10-07 12:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from tobi at gcc dot gnu dot org  2007-10-07 12:01 -------
(In reply to comment #3)
> I think we need to use tgamma() where available.  If it isn't, we
> need a test to check whether gamma() is equivalent to tgamma() or
> to lgamma().
> 
> Yuck.

It may be simpler to calculate it ourselves, perhaps lifting code form glibc.


-- 

tobi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tobi at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/33683] calculating lgamma instead of gamma
  2007-10-06 22:23 [Bug libfortran/33683] New: calculating lgamma instead of gamma tkoenig at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-10-07 12:02 ` tobi at gcc dot gnu dot org
@ 2007-10-07 16:48 ` tkoenig at gcc dot gnu dot org
  2007-10-07 18:43 ` jvdelisle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-10-07 16:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from tkoenig at gcc dot gnu dot org  2007-10-07 16:48 -------
This fixes things at least on my system; this also
passes regression-testing.

Index: mathbuiltins.def
===================================================================
--- mathbuiltins.def    (revision 129050)
+++ mathbuiltins.def    (working copy)
@@ -30,5 +30,5 @@ DEFINE_MATH_BUILTIN   (Y1,    "y1",     
 DEFINE_MATH_BUILTIN   (YN,    "yn",     2)
 DEFINE_MATH_BUILTIN   (ERF,   "erf",    0)
 DEFINE_MATH_BUILTIN   (ERFC,  "erfc",   0)
-DEFINE_MATH_BUILTIN   (GAMMA, "gamma",  0)
+DEFINE_MATH_BUILTIN   (GAMMA, "tgamma",  0)
 DEFINE_MATH_BUILTIN   (LGAMMA,"lgamma", 0)


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tkoenig at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-10-07 10:22:12         |2007-10-07 16:48:03
               date|                            |


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/33683] calculating lgamma instead of gamma
  2007-10-06 22:23 [Bug libfortran/33683] New: calculating lgamma instead of gamma tkoenig at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-10-07 16:48 ` tkoenig at gcc dot gnu dot org
@ 2007-10-07 18:43 ` jvdelisle at gcc dot gnu dot org
  2007-10-07 21:36 ` tkoenig at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-10-07 18:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jvdelisle at gcc dot gnu dot org  2007-10-07 18:43 -------
I have tested this on x86-64-linux.  It works here as well.  After reading the
man page myself, I think this is the answer and I would commit it as obvious.

The only question is what do other platforms do? AIX hp etc


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/33683] calculating lgamma instead of gamma
  2007-10-06 22:23 [Bug libfortran/33683] New: calculating lgamma instead of gamma tkoenig at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-10-07 18:43 ` jvdelisle at gcc dot gnu dot org
@ 2007-10-07 21:36 ` tkoenig at gcc dot gnu dot org
  2007-10-07 21:46 ` tkoenig at gcc dot gnu dot org
  2007-10-09 20:13 ` tkoenig at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-10-07 21:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from tkoenig at gcc dot gnu dot org  2007-10-07 21:36 -------
Subject: Bug 33683

Author: tkoenig
Date: Sun Oct  7 21:36:09 2007
New Revision: 129116

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129116
Log:
2007-10-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR libfortran/33683
        * mathbuiltins.def (GAMMA):  Change function name to
        "tgamma" instad of "gamma".

2007-10-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR libfortran/33683
        * gfortran.dg/gamma_5.f90:  New test case


Added:
    trunk/gcc/testsuite/gfortran.dg/gamma_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/mathbuiltins.def
    trunk/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/33683] calculating lgamma instead of gamma
  2007-10-06 22:23 [Bug libfortran/33683] New: calculating lgamma instead of gamma tkoenig at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2007-10-07 21:36 ` tkoenig at gcc dot gnu dot org
@ 2007-10-07 21:46 ` tkoenig at gcc dot gnu dot org
  2007-10-09 20:13 ` tkoenig at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-10-07 21:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from tkoenig at gcc dot gnu dot org  2007-10-07 21:45 -------
Fixed.

Let's close this and watch for occurences of
gamma_5.f90 failing, then open a new bug report
if that happens.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/33683] calculating lgamma instead of gamma
  2007-10-06 22:23 [Bug libfortran/33683] New: calculating lgamma instead of gamma tkoenig at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2007-10-07 21:46 ` tkoenig at gcc dot gnu dot org
@ 2007-10-09 20:13 ` tkoenig at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-10-09 20:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from tkoenig at gcc dot gnu dot org  2007-10-09 20:13 -------
Subject: Bug 33683

Author: tkoenig
Date: Tue Oct  9 20:13:18 2007
New Revision: 129174

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129174
Log:
2007-10-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR libfortran/33683
        * gfortran.dg/gamma_5.f90:  Adjust tolerance to avoid
        failure on some common systems.


Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/gamma_5.f90


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-10-09 20:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-06 22:23 [Bug libfortran/33683] New: calculating lgamma instead of gamma tkoenig at gcc dot gnu dot org
2007-10-06 22:28 ` [Bug libfortran/33683] " dominiq at lps dot ens dot fr
2007-10-06 23:04 ` fxcoudert at gcc dot gnu dot org
2007-10-07 10:22 ` tkoenig at gcc dot gnu dot org
2007-10-07 12:02 ` tobi at gcc dot gnu dot org
2007-10-07 16:48 ` tkoenig at gcc dot gnu dot org
2007-10-07 18:43 ` jvdelisle at gcc dot gnu dot org
2007-10-07 21:36 ` tkoenig at gcc dot gnu dot org
2007-10-07 21:46 ` tkoenig at gcc dot gnu dot org
2007-10-09 20:13 ` tkoenig at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).