From 96f71a9a6bf7b52c50a1f52d4d401a48dc40480f Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Fri, 20 Jun 2025 19:48:41 +0000 Subject: [PATCH] 8255082: HotSpot Style Guide should permit noexcept Reviewed-by: kvn, dholmes, dcubed --- doc/hotspot-style.html | 53 ++++++++++++++++++++++++++++++++++++++++++ doc/hotspot-style.md | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/doc/hotspot-style.html b/doc/hotspot-style.html index 22fd7b8167b..dafd29d6f54 100644 --- a/doc/hotspot-style.html +++ b/doc/hotspot-style.html @@ -87,6 +87,7 @@ id="toc-local-function-objects">Local Function Objects
  • Inheriting constructors
  • Attributes
  • +
  • noexcept
  • Additional Permitted Features
  • @@ -1140,6 +1141,58 @@ function name and the parameter list. memory_order_consume.
  • [[deprecated]] - Not relevant in HotSpot code.
  • +

    noexcept

    +

    Use of noexcept exception specifications (n3050) are permitted with restrictions +described below.

    + +

    HotSpot is built with exceptions disabled, e.g. compile with +-fno-exceptions (gcc, clang) or no /EH option +(MSVC++). So why do we need to consider noexcept at all? +It's because noexcept exception specifications serve two +distinct purposes.

    +

    The first is to allow the compiler to avoid generating code or data +in support of exceptions being thrown by a function. But this is +unnecessary, because exceptions are disabled.

    +

    The second is to allow the compiler and library code to choose +different algorithms, depending on whether some function may throw +exceptions. This is only relevant to a certain set of functions.

    + +

    HotSpot code can assume no exceptions will ever be thrown, even from +functions not declared noexcept. So HotSpot code doesn't +ever need to check, either with conditional exception specifications or +with noexcept expressions.

    +

    Dynamic exception specifications were deprecated in C++11. C++17 +removed all but throw(), with that remaining a deprecated +equivalent to noexcept.

    Additional Permitted Features