PATCH: remove const/pure attribute from builtin gamma/lgamma

Kaveh R. GHAZI
Thu Nov 2 14:29:00 GMT 2006

On Tue, 31 Oct 2006, Roger Sayle wrote:

> On Tue, 31 Oct 2006, Kaveh R. GHAZI wrote:
> > 2006-10-30  Kaveh R. Ghazi  <>
> >
> > 	* builtins.def (gamma, lgamma): Use ATTR_MATHFN_FPROUNDING_STORE.
> >
> > testsuite:
> > 	* gcc.dg/torture/builtin-attr-1.c: Don't test gamma/lgamma.
> > 	* gcc.dg/torture/builtin-convert-1.c: Don't test lgamma.
> This is OK for all branches.  Thanks.
> Who on earth comes up with these APIs?!  Does this mess things up for
> compile-time evalution, or do we need a -fno-signgam-math option! :-)
> Roger

I agree the C99 API is lame :-), it's also not thread safe.  For
compile-time evaluation, I might be able to wrap a compound expression
like I did for sincos.  E.g lgamma(foo) -> (signgam = bar, baz) where
"bar" is the sign value and "baz" is the lgamma result.

However there is a more serious problem with mpfr_lngamma, in that it does
not exactly correspond to c99's lgamma.  See

I'm trying to get the MPFR folks to resolve this.  I am optimistic that a
solution will be implemented, but whether it's in the next micro or major
MPFR release may depend on which solution is chosen.

Kaveh R. Ghazi

More information about the Gcc-patches mailing list