JDK-8214377 : ZGC: Don't use memset to initialize array of ZForwardingTableEntry
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-11-27
  • Updated: 2018-12-06
  • Resolved: 2018-12-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 12
12 b23Fixed
Related Reports
Relates :  
Description
Use placement new instead of memset() to avoid compiler warning/error when using GCC 8 with -Werror=class-memaccess (memset to initialize non-trivial object).

Fails in zForwardingTable.cpp:42:
 memset(_table, ZForwardingTableEntry::empty(), _size * sizeof(ZForwardingTableEntry));

Note that this setup() function is a bit performance sensitive, so the memset() here likely performs much better than a for-loop with placement new. An alternative would be to turn ZForwardingTableEntry into a trivial object and continue using memset(), but that requires some more code restructuring.

Once could perhaps also argue that (Mmap|Malloc)ArrayAllocator should do the placement new loop, so that it always returns a properly constructed array.