Skip to content

special_math.cpp: Investigate lgamma()/tgamma() error behavior #6417

Description

In #6413 we added implementations of lgamma() and tgamma() to special_math.cpp, powered by Boost.Math, as workarounds for their unavailability as compiler builtins, due to LLVM libc math not yet implementing them.

[[nodiscard]] _CRT_SATELLITE_2 double __stdcall __std_smf_lgamma(const double _Px) noexcept {
if (_STD isnan(_Px)) {
return _Px;
}
// TRANSITION, investigate handling C23 7.12.1 "Treatment of error conditions" and 7.12.8.3 "The lgamma functions".
return _Boost_call([=] { return ::boost::math::lgamma(_Px); });
}
[[nodiscard]] _CRT_SATELLITE_2 float __stdcall __std_smf_lgammaf(const float _Px) noexcept {
if (_STD isnan(_Px)) {
return _Px;
}
// TRANSITION, investigate handling C23 7.12.1 "Treatment of error conditions" and 7.12.8.3 "The lgamma functions".
return _Boost_call([=] { return ::boost::math::lgamma(_Px); });
}

[[nodiscard]] _CRT_SATELLITE_2 double __stdcall __std_smf_tgamma(const double _Px) noexcept {
if (_STD isnan(_Px)) {
return _Px;
}
// TRANSITION, investigate handling C23 7.12.1 "Treatment of error conditions" and 7.12.8.4 "The tgamma functions".
return _Boost_call([=] { return ::boost::math::tgamma(_Px); });
}
[[nodiscard]] _CRT_SATELLITE_2 float __stdcall __std_smf_tgammaf(const float _Px) noexcept {
if (_STD isnan(_Px)) {
return _Px;
}
// TRANSITION, investigate handling C23 7.12.1 "Treatment of error conditions" and 7.12.8.4 "The tgamma functions".
return _Boost_call([=] { return ::boost::math::tgamma(_Px); });
}

C23 7.12.1 "Treatment of error conditions", 7.12.8.3 "The lgamma functions", and 7.12.8.4 "The tgamma functions" appear to specify different behavior than what we're currently doing, which we should investigate.

This will become moot if LLVM libc implements lgamma() and tgamma() so MSVC can pick up these builtins.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions