RFR: 8252584: HotSpot Style Guide should permit alignas [v2]

Kim Barrett kbarrett at openjdk.org
Mon Nov 28 12:31:11 UTC 2022


On Sun, 27 Nov 2022 13:49:41 GMT, Julian Waters <jwaters at openjdk.org> wrote:

>> Add alignas to the permitted features set. Though the corresponding entry mentions this should not be done for classes, there's no actual difference in practice with all our supported compilers, because their nonstandard syntax also has the same limitations and issues with dynamic allocation as the C++ alignas, and including such a restriction of falling back to ATTRIBUTE_ALIGNED in the case of classes in the style guide would ultimately not really serve much of a point
>
> Julian Waters has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Rectify issues mentioned in review

Changes requested by kbarrett (Reviewer).

doc/hotspot-style.md line 657:

> 655: 
> 656: `alignas`
> 657: ([n1877](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1877.pdf))

n1877 is not the final version of the proposal; see [n2341](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf)

doc/hotspot-style.md line 667:

> 665: within HotSpot, at least until we switch to using C++17. See the review for
> 666: [JDK-8252584](https://github.com/openjdk/jdk/pull/11315)
> 667: for more information.

There have been a couple of relevant defect reports:
CWG 2354 - https://cplusplus.github.io/CWG/issues/2354.html
CWG 1437 - https://cplusplus.github.io/CWG/issues/1437.html

It turns out alignas must be applied to a definition, with declarations
optionally having alignas equivalent to the definition:
C++14 10.6.2/6 - https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf.

I found the structure of the proposed text somewhat difficult to follow.

Limits on the maximum alignment need to be explored and documented.  The
maximum for an automatic variable might be significantly limited, or maybe
just risks blowing the stack.  I think we don't have any existing uses of
aligned automatic variables, so maybe we don't need to permit them?  For now
I'll leave that in place, but I could easily be convinced to remove it.

So I suggest something like the following:
https://github.com/openjdk/jdk/compare/master...kimbarrett:openjdk-jdk:alignas?expand=1

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

PR: https://git.openjdk.org/jdk/pull/11315


More information about the hotspot-dev mailing list