RFR: 8338449: ubsan: division by zero in sharedRuntimeTrans.cpp
Kim Barrett
kbarrett at openjdk.org
Tue Oct 22 21:57:04 UTC 2024
On Tue, 22 Oct 2024 04:11:43 GMT, Joe Darcy <darcy at openjdk.org> wrote:
>> Never mind my question about whether this was happening with clang as the compiler rather than gcc.
>> Our ubsan configuration explicitly includes `-fsantize=float-divide-by-zero`.
>> https://github.com/openjdk/jdk/blame/8bcd4920f1b03d0ef8e295e53557c629f05ceaa4/make/autoconf/jdk-options.m4#L516
>
>> I'm not sure what the implications of this actually are. Do we really need it? Maybe @jddarcy can comment?
>
> Catching up on email, whatever the appropriate C/C++ idiom is, it is appropriate for this file to assert "use IEEE 754 semantics for floating-point operations." The divide by zero behavior is well-defined by IEEE 754/IEC 559.
It's not clear there is any in-language mechanism (whether portable or compiler-specific) for reliably requesting or verifying that one will get that behavior. A static_assert of is_iec599 _might_ be sufficient verification, but the standard is at least unclear on that. But that seems to be the best we've got.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21500#discussion_r1811490684
More information about the hotspot-dev
mailing list