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

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


On Sat, 31 Dec 2022 17:14:47 GMT, Julian Waters <jwaters at openjdk.org> wrote:

>> 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

Something like this perhaps?

- Prefer `alignof` ([n2341](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf)) to `std::alignment_of<>`. The template has been superseded by the newer operator.

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

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


More information about the hotspot-dev mailing list