HomeFreeBSD

[libm] Fix undefined behavior of a left shifted of a signed integer

Description

[libm] Fix undefined behavior of a left shifted of a signed integer

The patch fixes a few instances of left shifts on
signed integer entities. A 'static inline' helper function
'subnormal_ilogb()' has been added to math_private.h. This
function is then used e_fmod.c, s_ilogb(), and s_remquo.c.

The change in s_remquo.c has only been compile tested.

The change to e_fmod.c has been test on over 3 billion pairs
of subnormal numbers where testing included x > y and x < y
pairs. The test compared the output from fmod() with the
output from mpfr_fmod() from MPFR. There were no difference.

The change to s_ilogb() has had limited testing where its
output was compared against frexp(). In this testing, no
differences in output were detected.

PR: 288778
MFC after: 1 week

(cherry picked from commit d180086e6eae2e152e803ed6cf13775a7c006dc7)

Details

Provenance
Steve Kargl <kargl@FreeBSD.org>Authored on Aug 12 2025, 4:26 AM
dimCommitted on Aug 21 2025, 10:41 AM
Parents
rGe84d5425bf53: dtrace.1: Document security.bsd.allow_destructive_dtrace
Branches
Unknown
Tags
Unknown