Make Atomic class template constant initializable

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • 27
    • Affects Version/s: None
    • Component/s: hotspot

      All of the the constructors for the various Atomic<T> types should be constexpr. This will ensure the initialization of a non-local atomic variable be constant initialization (C++17 6.6.2) if the (possibly defaulted) initial value is provided by a constant expression.

      This simplifies the use of atomic variables. In the common case where the initial value is defaulted or proved by a constant expression, there is no need to worry about whether the variable will be dynamically initialized. While it's likely a compiler would reduce the dynamic initialization to constant initialization, making the constructors constexpr guarantees constant initialization with suitable arguments. Without such a guarantee of constant initialization one might wonder whether DeferredStatic or some other mechanism is needed, per the HotSpot Style Guide.

            Assignee:
            Kim Barrett
            Reporter:
            Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: