RFR: 8275717: Reimplement STATIC_ASSERT to use static_assert

Thomas Stuefe stuefe at openjdk.java.net
Fri Oct 22 13:00:03 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?

LGTM.

How do the asserts at build time look like?

I'm in favor of retaining the macro since it enables us to add support for non-compliant compilers and keeps backporting simple.

Thanks, Thomas

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

Marked as reviewed by stuefe (Reviewer).

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


More information about the hotspot-dev mailing list