RFR: 8275717: Reimplement STATIC_ASSERT to use static_assert

Stefan Karlsson stefank at openjdk.java.net
Fri Oct 22 08:23:13 UTC 2021


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?

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

Commit messages:
 - 8275717: Reimplement STATIC_ASSERT to use static_assert

Changes: https://git.openjdk.java.net/jdk/pull/6077/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6077&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8275717
  Stats: 16 lines in 1 file changed: 0 ins; 15 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6077.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6077/head:pull/6077

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


More information about the hotspot-dev mailing list