Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays
Date
Msg-id 13532.1570039353@sss.pgh.pa.us
Whole thread Raw
In response to Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Mark Dilger <hornschnorter@gmail.com>)
Responses Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Mark Dilger <hornschnorter@gmail.com>)
List pgsql-hackers
Mark Dilger <hornschnorter@gmail.com> writes:
> On 10/2/19 8:46 AM, Tom Lane wrote:
>> Right.  I think that in general it's bad practice for an initializer
>> to not specify all fields/elements of the target.

> There are numerous locations in the code that raise warnings when
> -Wmissing-field-initializers is handed to gcc.  See, for example, 
> src/backend/utils/adt/formatting.c where
>    static const KeyWord NUM_keywords[]
> is initialized, and the code comment above that disclaims the need to 
> initialize is_digit and date_mode.  Are you proposing cleaning up all 
> such incomplete initializations within the project?

Hmm.  Maybe it's worth doing as a code beautification effort, but
I'm not volunteering.  At the same time, I wouldn't like to make a
change like this, if it introduces dozens/hundreds of new cases.

> I understand that your INIT_ALL_ZEROS macro does nothing to change
> whether -Wmissing-field-initializers would raise a warning.

Not sure --- the name of that option suggests that maybe it only
complains about omitted *struct fields* not omitted *array elements*.

If it does complain, is there any way that we could extend the macro
to annotate usages of it to suppress the warning?

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Hooks for session start and end, take two
Next
From: Robert Haas
Date:
Subject: Re: WIP: Generic functions for Node types using generated metadata