RFR: 8274400: HotSpot Style Guide should permit use of alignof [v5]
Kim Barrett
kbarrett at openjdk.org
Sun Jan 22 21:24:07 UTC 2023
On Wed, 4 Jan 2023 13:23:08 GMT, Julian Waters <jwaters at openjdk.org> wrote:
>> The alignof operator was added by C++11. It returns the alignment for the given type. Various metaprogramming usages exist, in particular when using std::aligned_storage. Use of this operator should be permitted in HotSpot code.
>
> Julian Waters has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains ten additional commits since the last revision:
>
> - Hopefully final change
> - Merge remote-tracking branch 'upstream/master' into alignof
> - <type_traits>
> - Merge remote-tracking branch 'upstream/master' into alignof
> - Make section more brief
> - Merge remote-tracking branch 'upstream/master' into alignof
> - More Descriptive Version
> - Merge remote-tracking branch 'upstream/master' into alignof
> - HotSpot Style Guide should permit use of alignof
Changes requested by kbarrett (Reviewer).
doc/hotspot-style.md line 578:
> 576: * `#include <cstddef>` to use `std::nullptr_t` and `std::max_align_t`.
> 577:
> 578: Certain restrictions apply to the inclusion of `<type_traits>`.
There are no restrictions on the inclusion of <type_traits>. Rather, there are restrictions on the
use of the declarations provided by <type_traits>.
doc/hotspot-style.md line 580:
> 578: Certain restrictions apply to the inclusion of `<type_traits>`.
> 579:
> 580: * The `alignof` operator should always be preferred over `std::alignment_of<>`.
I would really like to avoid "prefer" here. Even though "always preferred" has
the right meaning, I've always thought that was a clumsy turn of phrase,
unconditionalizing a conditional. Also "prefer over" read oddly to to me. It
seems to be a less commonly used American English usage, with "prefer to"
being more common. (And "prefer to" seems exclusively used in British English,
with "prefer over" not being a thing in that dialect.)
"Use the `alignof` operator rather than `std::alignment_of`."
-------------
PR: https://git.openjdk.org/jdk/pull/11761
More information about the hotspot-dev
mailing list