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

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 11 Aug 2025 20:20:14 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=288778

--- Comment #1 from Steve Kargl <kargl@FreeBSD.org> ---
So, a bit of code spelunking shows that the issue raised
at https://github.com/freebsd/freebsd-src/pull/1752 is
simply to appease a sanitizer.  The C language standard
does state that a left-shift of a signed integer ventures
into undefined behavior.

The code that my patch touches in e_fmod.c is identical
to the code at https://www.netlib.org/fdlibm/e_fmod.c,
which was released 32+ years ago.  The fdlibm code is
also the code that appears in openbsd and netbsd.  I
have been unable to find any bug report involving this
code fragment about wrong results.  I suspect we can
conclude that the undefined behavior of the C standard
is well-defined by the compilers (barring a dive into
options) used by FreeBSD.

-- 
You are receiving this mail because:
You are the assignee for the bug.