@@ -72,7 +72,6 @@ <h1 class="title">HotSpot Coding Style</h1>
7272< li > < a href ="#expression-sfinae " id ="toc-expression-sfinae "> Expression
7373SFINAE</ a > </ li >
7474< li > < a href ="#enum " id ="toc-enum "> enum</ a > </ li >
75- < li > < a href ="#alignas " id ="toc-alignas "> alignas</ a > </ li >
7675< li > < a href ="#thread_local " id ="toc-thread_local "> thread_local</ a > </ li >
7776< li > < a href ="#nullptr " id ="toc-nullptr "> nullptr</ a > </ li >
7877< li > < a href ="#atomic " id ="toc-atomic "> <atomic></ a > </ li >
@@ -599,7 +598,7 @@ <h3 id="c-standard-library">C++ Standard Library</h3>
599598< code > std::numeric_limits</ code > .</ li >
600599< li > < code > #include <type_traits></ code > .</ li >
601600< li > < code > #include <cstddef></ code > to use
602- < code > std::nullptr_t</ code > and < code > std::max_align_t </ code > .</ li >
601+ < code > std::nullptr_t</ code > .</ li >
603602</ ul >
604603< p > TODO: Rather than directly #including (permitted) Standard Library
605604headers, use a convention of #including wrapper headers (in some
@@ -671,52 +670,6 @@ <h3 id="enum">enum</h3>
671670constant members. Compilers having such bugs are no longer supported.
672671Except where an enum is semantically appropriate, new code should use
673672integral constants.</ p >
674- < h3 id ="alignas "> alignas</ h3 >
675- < p > < em > Alignment-specifiers</ em > (< code > alignas</ code > < a
676- href ="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf "> n2341</ a > )
677- are permitted, with restrictions.</ p >
678- < p > < em > Alignment-specifiers</ em > are permitted when the requested
679- alignment is a < em > fundamental alignment</ em > (not greater than
680- < code > alignof(std::max_align_t)</ code > < a
681- href ="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf "> C++14
682- 3.11/2</ a > ).</ p >
683- < p > < em > Alignment-specifiers</ em > with an < em > extended alignment</ em >
684- (greater than < code > alignof(std::max_align_t)</ code > < a
685- href ="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf "> C++14
686- 3.11/3</ a > ) may only be used to align variables with static or automatic
687- storage duration (< a
688- href ="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf "> C++14
689- 3.7.1, 3.7.3</ a > ). As a consequence, < em > over-aligned types</ em > are
690- forbidden; this may change if HotSpot updates to using C++17 or later < a
691- href ="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0035r4.html "> p0035r4</ a > .</ p >
692- < p > Large < em > extended alignments</ em > should be avoided, particularly
693- for stack allocated objects. What is a large value may depend on the
694- platform and configuration. There may also be hard limits for some
695- platforms.</ p >
696- < p > An < em > alignment-specifier</ em > must always be applied to a
697- definition (< a
698- href ="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf "> C++14
699- 10.6.2/6</ a > ). (C++ allows an < em > alignment-specifier</ em > to optionally
700- also be applied to a declaration, so long as the definition has
701- equivalent alignment. There isn't any known benefit from duplicating the
702- alignment in a non-definition declaration, so such duplication should be
703- avoided in HotSpot code.)</ p >
704- < p > Enumerations are forbidden from having < em > alignment-specifiers</ em > .
705- Aligned enumerations were originally permitted but insufficiently
706- specified, and were later (C++20) removed < a
707- href ="https://cplusplus.github.io/CWG/issues/2354.html "> CWG 2354</ a > .
708- Permitting such usage in HotSpot now would just cause problems in the
709- future.</ p >
710- < p > < em > Alignment-specifiers</ em > are forbidden in < code > typedef</ code >
711- and < em > alias-declarations</ em > . This may work or may have worked in
712- some versions of some compilers, but was later (C++14) explicitly
713- disallowed < a
714- href ="https://cplusplus.github.io/CWG/issues/1437.html "> CWG
715- 1437</ a > .</ p >
716- < p > The HotSpot macro < code > ATTRIBUTE_ALIGNED</ code > provides similar
717- capabilities for platforms that define it. This macro predates the use
718- by HotSpot of C++ versions providing < code > alignas</ code > . New code
719- should use < code > alignas</ code > .</ p >
720673< h3 id ="thread_local "> thread_local</ h3 >
721674< p > Avoid use of < code > thread_local</ code > (< a
722675href ="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm "> n2659</ a > );
0 commit comments