Subject: Re: [PATCH 3/5] reftable/stack: fix compiler warning due to missing braces

From: Patrick Steinhardt <[email-masked]>
Date: Mon, 4 Aug 2025 08:03:20 +0200

On Fri, Aug 01, 2025 at 03:19:52PM -0400, Eric Sunshine wrote:
> On Fri, Aug 1, 2025 at 10:48 AM Patrick Steinhardt <[email-masked]> wrote:
> > While perfectly legal, older compiler toolchains complain when
> > zero-initializing structs that contain nested structs with `{0}`:
> > [...]
> > Silence this warning by using `{{0}}` instead.
> >
> > Signed-off-by: Patrick Steinhardt <[email-masked]>
> > ---
> > diff --git a/reftable/stack.c b/reftable/stack.c
> > -#define REFTABLE_ADDITION_INIT {0}
> > +#define REFTABLE_ADDITION_INIT {{0}}
> 
> For what it's worth, the last time this sort of issue came up[*], I
> believe the ultimate response was that the project ought not pander to
> this particular instance of buggy compiler and that, instead, an
> individual developer should, if bothered by the warning, use the
> appropriate compiler option to suppress the warning. Whether or not
> that attitude should apply also to the reftable code which is meant to
> be shareable, is a separate question, but at least that previous
> discussion thread provides some background regarding how different
> developers feel or felt about the issue.
> 
> [*]: https://lore.kernel.org/git/[email-masked]/T/

Yeah, in general I'm also of the opinion that we shouldn't bother. But
in libgit2 we have pipelines that use such older compilers, and we don't
want to drop those for now. So I think we should treat the reftable
library specially, doubly so as this is the only instance that causes
problems.

Thanks for digging up that old thread!

Patrick