RFR: 8358104: Fix ZGC compilation error on GCC 10.2

Qizheng Xing qxing at openjdk.org
Fri May 30 07:40:50 UTC 2025


On Fri, 30 May 2025 07:07:04 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> JDK-8350441 introduced Mapped Cache for ZGC. However, the constructor of `ZMappedCache` uses brace-initialization for `_size_class_lists`, i.e. a `ZList` array. `ZList` is a class with a deleted copy constructor and an explicit destructor, and when its array is brace-initialized in the constructor, it triggers [GCC bug 63707](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63707). A short example to reproduce this bug: https://godbolt.org/z/3397bxc73
>> 
>> The bug causes compilation error of ZGC on GCC versions 10.1 to 10.2. Considering OpenJDK compilation is still requires GCC 10 or higher, this should be recorded as a bug.
>> 
>> This patch uses value-initialization for `_size_class_lists` instead of brace-initialization, which should be semantically equivalent and work on all GCC versions.
>
> The change seems okay, though a bit disappointing that it's needed.
> 
> The referenced gcc bug seems to have been fixed in gcc11, with backports to
> gcc10.3 and gcc9.4.  The minimum supported compiler version has always been
> somewhat approximate, since there isn't regular testing reported for what are
> often rather old versions. Sometimes we just decide to force an update to the
> required minimum rather than working around an issue like this.
> 
> I wonder why that version is still in use?

@kimbarrett Thanks for your review!

> I wonder why that version is still in use?

My development environment is an Alibaba Cloud ECS server, with Alibaba Cloud Linux 3.2104 LTS. The default C++ compiler in this OS happens to be GCC 10.2.1.

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

PR Comment: https://git.openjdk.org/jdk/pull/25536#issuecomment-2921491503


More information about the hotspot-gc-dev mailing list