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.
Updated by nobu (Nobuyoshi Nakada) 1 day ago
Updated by nobu (Nobuyoshi Nakada) 1 day ago
- Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED
Updated by mtasaka (Mamoru TASAKA) 1 day ago
https://github.com/ruby/ruby/compare/master...nobu:ruby:lgamma-unspecified-values?expand=1
Thank you. I've checked the above change and as far as I read the specification (POSIX) this is correct.
Updated by mtasaka (Mamoru TASAKA) 1 day ago
To be sure, I will try building and run test with Fedora glibc-2.42.9000-8.fc44 (after applying the above PR)
Updated by mtasaka (Mamoru TASAKA) 1 day ago
Okay, lgamma testsuite now seems good after applying https://github.com/ruby/ruby/pull/15076 with Fedora glibc-2.42.9000-8.fc44