RFR: 8357579: Compilation error: first argument in call to 'memset' is a pointer to non-trivially copyable type [v13]
Ashutosh Mehra
asmehra at openjdk.org
Mon Nov 10 22:18:05 UTC 2025
On Mon, 10 Nov 2025 20:20:02 GMT, Jan Kratochvil <jkratochvil at openjdk.org> wrote:
>> 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).
Okay.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26098#discussion_r2512145283
More information about the hotspot-dev
mailing list