On Fri, Oct 4, 2019 at 8:49 AM Tom Lane <t...@sss.pgh.pa.us> wrote:

> Jacob Champion <pchamp...@pivotal.io> writes:
> > On Fri, Oct 4, 2019 at 7:51 AM Tom Lane <t...@sss.pgh.pa.us> wrote:
> >> I concur with Joe here.  The reason why some of the existing
> >> memset's use "false" is for symmetry with other places where we use
> >> "memset(p, true, n)" to set an array of bools to all-true.
>
> > Why introduce a macro at all for the universal zero initializer, if it
> > seems to encourage the construction of other (incorrect) macros?
>
> Well, the argument is that some people might think that if {0} is enough
> to set all array elements to 0, then maybe {1} sets them all to ones
> (as, indeed, one could argue would be a far better specification than
> what the C committee actually wrote).  Using a separate macro and then
> discouraging direct use of the incomplete-initializer syntax should help
> to avoid that error.
>

Seems avoidable overhead to remind folks on macro existence. Plus, for such
a thing macro exist in first place will be hard to remember. So,
irrespective in long run, {0} might get used in code and hence seems better
to just use {0} from start itself instead of macro/wrapper on top.

Plus, even if someone starts out with thought {1} sets them all to ones, I
feel will soon realize by exercising the code isn't the reality. If such
code is written and nothing fails, that itself seems bigger issue.

Reply via email to