[jdk11u-dev] RFR: 8324307: [11u] hotspot fails to build with GCC 12 and newer (non-static data member initializers)

Jonathan Dowland jdowland at openjdk.org
Mon Feb 5 16:09:07 UTC 2024


On Wed, 31 Jan 2024 08:10:11 GMT, Goetz Lindenmaier <goetz at openjdk.org> wrote:

>> GCC 12 and newer warn about non-static data member initialisers when operating under -std=gnu++98 (jdk11u-dev's C++ standards version). These warnings are promoted to errors by default.
>> 
>> This is an issue for jdk11u-dev which uses the C++ standard version '-std=gnu++98'. It is not an issue for later JDK versions which have moved to newer standards (JEP 347 moved JDK16 to -std=c++14): therefore an 11u-specific fix is required.
>> 
>> The approach used in this PR is to remove the initialisers, in common with what we did when backporting the same code to jdk8u-dev.
>
> Removing the tag in the meantime

Hi @GoeLin ,
> @jmtd, if these initializers are not needed at all, shouldn't they be removed in the higher releases as well?

This is a really good question and I took some time to ponder my reply.

They are not needed from a computational POV because the relevant fields are all initialised in the object constructors in all cases. However, to know this I had to read through the class definition to be sure.  I didn't write the original code but if I had I would have likely also preferred an explicit null initialisation in the member declaration, which makes clear the intent that we do not have uninitialised fields and do not risk reading from uninitialised fields. There's a chance the constructor could be altered later and an iniitialisation accidentally removed, or an alternative constructor added lacking the initialisation, etc.

I doubt that anyone would welcome a patch to remove the redundant initialisers in main, but I could propose one if you disagree. WDYT?

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

PR Comment: https://git.openjdk.org/jdk11u-dev/pull/2470#issuecomment-1927337917


More information about the jdk-updates-dev mailing list