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

John R Rose jrose at openjdk.org
Thu Dec 1 00:56:52 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

Given that this declaration thingy has no portable meaning beyond max-align, it seems to be actually dangerous to use, for at least some of our use cases in HotSpot.  And for the use cases within max-align, the usual workarounds with unions and what-not will do the job, almost always.

In short, this syntax seems like the sort of sugary flaky treat we should avoid.  Making our sources less portable in order to make them more beautiful would be a bad bargain.

The ugly-but-reliable way we control stuff like is to concoct some kind of ugly macro, local to HotSpot, that has exactly the semantics that we require, and that is portable.

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

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


More information about the hotspot-dev mailing list