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.
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.
- relates to
-
JDK-8213153 Clean up GCC 8 errors
- Closed