RFR: 8338449: ubsan: division by zero in sharedRuntimeTrans.cpp
Kim Barrett
kbarrett at openjdk.org
Tue Oct 22 20:22:05 UTC 2024
On Tue, 22 Oct 2024 19:27:56 GMT, Dean Long <dlong at openjdk.org> wrote:
> If this file requires certain IEEE divide-by-zero semantics, then should we also add static asserts for those? Something like: static_assert(-1.0 / 0.0 == -INFINITY, "IEEE 754 required"); static_assert(1.0 / 0.0 == INFINITY, "IEEE 754 required"); static_assert(std::isnan(0.0 / 0.0), "IEEE 754 required");
These expressions are UB, so not constexpr, so shouldn't be usable in a static_assert. And indeed, gcc says
static_assert_iec599.cpp:4:27: error: non-constant condition for static assertion
4 | static_assert(1.0 / 0.0 == INFINITY, "1/0 failed");
| ^
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21500#issuecomment-2430180370
More information about the hotspot-dev
mailing list