Bug #21666
openMath.lgamma(-1).should == [infinity_value, 1] fails with Fedora glibc-2.42.9000-8.fc44
Description
With Fedora glibc-2.42.9000-8.fc44 the following test:
fails like
1)
Math.lgamma returns [Infinity, 1] when passed -1 FAILED
Expected [Infinity, -1] == [Infinity, 1]
to be truthy but was false
/builddir/build/BUILD/ruby-3.5.0_20251103.2332git4001e81a8e-build/ruby-3.5.0-4001e81a8e/spec/ruby/core/math/lgamma_spec.rb:10:in 'block (3 levels) in <top (required)>'
/builddir/build/BUILD/ruby-3.5.0_20251103.2332git4001e81a8e-build/ruby-3.5.0-4001e81a8e/spec/ruby/core/math/lgamma_spec.rb:3:in '<top (required)>'
(With the help from glibc developer: https://bugzilla.redhat.com/show_bug.cgi?id=2412227 )
POSIX.1-2024 says (ref: https://pubs.opengroup.org/onlinepubs/9799919799/functions/lgamma.html )
If (x) is a non-positive integer, a pole error shall occur and
lgamma(), lgammaf(), and lgammal() shall return +HUGE_VAL, +HUGE_VALF, and +HUGE_VALL, respectively.
but also says:
The sign of ( \Gamma(x) ) shall be returned in the external integer signgam.
If (x) is NaN, -Inf, or a negative integer, the value of signgam is unspecified.`
So on this line:
https://github.com/ruby/ruby/blob/cdcb490d2bceb4ff8d6fce349047a2b722e6ae87/math.c#L1103
when d is -1 (or negative integer), the value of sign is unspeficied.
No data to display