Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8298399

HotSpot Style Guide should forbid std::aligned_storage<> and std::aligned_union<>

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 20
    • hotspot

      Forbid the use of std::aligned_storage and std::aligned_union in HotSpot. These are defined in <type_traits>, which is otherwise permitted for use. There is a proposal for deprecation (C++23)
      https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1413r3.pdf
      with a long list of problems with these types.

      Earlier versions of the paper contained proposed replacements, but the committee rejected that part, presumably because many of the issues can be addressed by just using alignas. Though that doesn't solve all problems, since reinterpret_cast is still needed, and alignas doesn't propagate through type aliases.
      https://www.reddit.com/r/cpp/comments/ceu0wd/why_are_stdaligned_storage_and_stdaligned_union/

            Unassigned Unassigned
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: