RFR: 8274400: HotSpot Style Guide should permit use of alignof [v4]

Julian Waters jwaters at openjdk.org
Sat Dec 31 17:17:51 UTC 2022


On Sat, 31 Dec 2022 04:18:44 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> 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 seven additional commits since the last revision:
>> 
>>  - <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
>
> doc/hotspot-style.md line 581:
> 
>> 579: 
>> 580: * `std::alignment_of<>` has been superseded by `alignof`, and the newer
>> 581: operator should be preferred over it instead, whenever possible.
> 
> No need for weasel words like "whenever possible".  Simply
> 
> * `std::alignment_of<>`. It has been superseded by `alignof` expressions.

I'm not sure if it's a good idea to entirely forbid `std::alignment_of<>`? While `alignof` should be used over it most of the time, I'm somewhat certain it and it's other counterpart from C++17 (may) have certain differences from `alignof` in newer versions of the language (especially when used with templates and in metaprogramming contexts), which is why I chose to avoid having to take those issues into account for now by simply saying the latter should always be preferred over the former (Similar to how nullptr vs NULL is discussed in the Style Guide). Maybe I could word it better though

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

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


More information about the hotspot-dev mailing list