RFR: JDK-8306304: Fix xlc17 clang warnings in ppc and aix code [v2]

Kim Barrett kbarrett at openjdk.org
Wed May 17 09:47:46 UTC 2023


On Mon, 15 May 2023 09:34:28 GMT, JoKern65 <duke at openjdk.org> wrote:

>> src/hotspot/os/aix/os_aix.cpp line 464:
>> 
>>> 462:       guarantee0(shmid != -1); // Should always work.
>>> 463:       // Try to set pagesize.
>>> 464:       struct shmid_ds shm_buf = { {0,0,0,0,0,0,0,0},0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
>> 
>> Would just `= {};` work?  (I think it should, but with warnings who knows...)
>
> os_aix.cpp:460:37: error: missing field 'gid' initializer [-Werror,-Wmissing-field-initializers]
>       struct shmid_ds shm_buf = { 0 };
> 
> ={} seems to work, but I do not know if it works on every compiler because standard says: the initializer must be a **non-empty, (until C23)** brace-enclosed, comma-separated list of initializers for the members.
> Should I then disable Warning missing-field-initializers?

Use

struct shmid_ds shm_buf{};

to _value-initialize_.  Calls the default constructor if there is one. Otherwise, performs _zero-initialization_,
which is what we want here.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13953#discussion_r1196232015


More information about the hotspot-dev mailing list