RFR: 8357579: Compilation error: first argument in call to 'memset' is a pointer to non-trivially copyable type [v13]

Jan Kratochvil jkratochvil at openjdk.org
Mon Nov 10 20:22:40 UTC 2025


On Mon, 10 Nov 2025 15:04:42 GMT, Ashutosh Mehra <asmehra at openjdk.org> wrote:

>> Jan Kratochvil has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Add Ioi Lam's comment
>
> src/hotspot/share/oops/resolvedFieldEntry.cpp line 31:
> 
>> 29: STATIC_ASSERT(std::is_trivially_copyable_v<ResolvedFieldEntry> == true);
>> 30: 
>> 31: // Detect inadvertently introduced trailing padding.
> 
> Another way to detect padding (trailing or internal) could be to compare sizeof(ResolvedFieldEntry) against the sum up the size of all the elements. Something like:
> `sizeofResolvedFieldEntry) == (sizeof(InstanceKlass*) + sizeof(int) + sizeof(u2) + ... + sizeof(_padding))`
> It looks cumbersome but I think it is easy enough to update if a new field is added because the static assert will fail immediately.

I can implement this plan if requested, but I do not intend to do so on my own.
Thanks for the idea, but one could argue that some reformatting could still produce a false PASS. I would suggest that this is better left for [C++26 Reflection](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26098#discussion_r2511858818


More information about the hotspot-dev mailing list