RFR: 8275717: Reimplement STATIC_ASSERT to use static_assert

Kim Barrett kbarrett at openjdk.java.net
Fri Oct 22 15:44:09 UTC 2021


On Fri, 22 Oct 2021 08:15:52 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

> We currently have a bespoke implementation of STATIC_ASSERT, which was added before we transitioned over to C++14. I recently saw some compiler warnings (macos-aarch64) about that implementation. I propose that we reimplement STATIC_ASSERT to use static_assert. FWIW, some HotSpot code already uses static_assert instead of STATIC_ASSERT.
> 
> An alternative would be to completely remove STATIC_ASSERT and always use static_assert. That would require us to add a message string to all of the > 400 usages. Maybe we should wait with that until we can use C++17, which removes the requirement to provide a message?

Looks good.

The "unused typedef" warnings suggest a build with `-Wunused-local-typedefs` enabled.  I thought we were not enabling that (because it's not actually useful), but don't see such disabling and it's enabled by `-Wall`.  So why aren't we getting those warnings in any function where we use STATIC_ASSERT, for any gcc-based platform?

-------------

Marked as reviewed by kbarrett (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/6077


More information about the hotspot-dev mailing list