RFR: 8346914: UB issue in scalbnA
Kim Barrett
kbarrett at openjdk.org
Tue Jun 17 20:42:30 UTC 2025
On Tue, 17 Jun 2025 06:58:02 GMT, David Holmes <dholmes at openjdk.org> wrote:
> > The JBS issue also talks about `copysignA` and suggests we should just use `copysign` if we're keeping `scalbnA`. Please either address that here or file a new issue for `copysignA`.
>
> It doesn't really suggest that it simply says "is there a reason to prefer copysignA over the <math.h> copysign? ". I don't have an answer to that any more than I can answer the scalbnA versus scalbn question. You need to a libmath expert to answer those types of questions. All I have tried to do here is address the UB that was spotted.
OK, I'll be more direct than I was in JBS.
We don't need copysignA. Just use copysign from <math.h>.
Rationale: Long ago we had our own copysign, because we couldn't get it from
<math.h>. It's a C99 function. For gcc/clang we were using C++98/03, which
only includes C89 library functions. So gcc/clang <math.h> version restricted
it out. And MSVC++ <math.h> didn't have it at all. Later, MSVC++ added
copysign, without any version restriction since they didn't do Standard
versions back then. This collided with ours, so we renamed ours. Later still
we switched to C++14, which includes C99 library functions, so it's no longer
version restricted by gcc/clang. So we no longer need our own, and should just
use the one from <math.h>.
Whether this is done under this issue or a new one, I don't really care, so long
as the issue isn't lost.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25656#issuecomment-2981770338
More information about the hotspot-dev
mailing list