RFR: 8252584: HotSpot Style Guide should permit alignas
Kim Barrett
kbarrett at openjdk.org
Sat Nov 26 04:20:53 UTC 2022
On Wed, 23 Nov 2022 10:24:42 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
No. Any proposal to permit `alignas` needs to address questions around
"extended alignment", and especially "over-aligned types". Note that support
for extended alignment in any particular context is implementation defined.
(C++14 3.11/3)
It looks like nearly all uses of compiler-specific alignment decorations (such
as `__attribute__((aligned))`) in HotSpot are on variables with static
duration. I think those are probably fine. (Early gcc implementations of
`alignas` were pretty limited (more so than `__attribute__((aligned))` from
what I found on the web), but that seems to have been fixed.)
The only exceptions I found are uses of ZCACHE_ALIGN on class data
members, which doesn't actually ensure alignment of those members!
-------------
PR: https://git.openjdk.org/jdk/pull/11315
More information about the hotspot-dev
mailing list