RFR: 8357579: Compilation error: first argument in call to 'memset' is a pointer to non-trivially copyable type [v7]
Jan Kratochvil
jkratochvil at openjdk.org
Fri Nov 7 16:31:53 UTC 2025
On Fri, 7 Nov 2025 15:58:56 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> This STATIC_ASSERT does work for the trailing padding but not for potential padding introduced inside the struct. That sizeof(x)==number of mine is also not foolproof, but IMHO it is slightly safer.
>
> I don't think either approach can detect internal padding. E.g., I changed this:
>
>
> # ifdef _LP64
> - u2 _padding1;
> + u1 _padding1;
> u4 _padding2;
>
>
> Neither static assert failed.
>
> But if I changed this:
>
>
> # ifdef _LP64
> u2 _padding1;
> - u4 _padding2;
> + u2 _padding2;
>
>
> My assert fails but yours doesn't. So hard coding a number cannot detect trailing paddings.
True. So I have added both. That sizeof check is for the case of:
} _entry_specific;
+ void *_new_pointer;
u2 _cpool_index; // Constant pool index
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26098#discussion_r2504453294
More information about the hotspot-dev
mailing list