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

From Joe Nelson
Subject Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays
Date
Msg-id 20191002153420.5cdf4ucnq7r3mnjq@begriffs.com
Whole thread Raw
In response to Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Isaac Morland <isaac.morland@gmail.com>)
Responses Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Isaac Morland <isaac.morland@gmail.com>)
List pgsql-hackers
Isaac Morland wrote:
> I hope you'll forgive a noob question. Why does the "After"
> initialization for the boolean array have {0} rather than {false}?

I think using a value other than {0} potentially gives the incorrect
impression that the value is used for *all* elements of the
array/structure, whereas it is only used for the first element. "The
remainder of the aggregate shall be initialized implicitly the same as
objects that have static storage duration."

The rest of the elements are being initialized to zero as interpreted by
their types (so NULL for pointers, 0.0 for floats, even though neither
of them need be bitwise zero). Setting the first item to 0 matches that
exactly.

Using {false} may encourage the unwary to try

    bool foo[2] = {true};

which will not set all elements to true.



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Possible bug: SQL function parameter in window frame definition
Next
From: Tom Lane
Date:
Subject: Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays