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

Xin Liu xliu at openjdk.org
Sat Jan 28 00:06:18 UTC 2023


On Tue, 24 Jan 2023 23:23:24 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> In order to access through an object, the object must be correctly aligned for its type, else UB.

hi, @kimbarrett, 
Thanks you for letting me know `alignof`.

I know the concept of 'nature alignment'. an object is aligned to its size. The rule is enforced by C/C++ compiler. Is it really UB if I violate it? 

In this case, sizeof(Message) is 64. I don't think we have to put an instance of Message at an address which can be divided by 64. In particular, Message is POD. We would like to have compact 'buffer'.

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

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


More information about the hotspot-dev mailing list