git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: "Han Xin" <chiyutianyi@gmail.com>,
	"Git List" <git@vger.kernel.org>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH] unpack-objects: fix compilation warning/error due to missing braces
Date: Sun, 10 Jul 2022 21:38:29 -0700	[thread overview]
Message-ID: <xmqq7d4kp8l6.fsf@gitster.g> (raw)
In-Reply-To: <CAPig+cQJWgerk08j=1b=aWRZsKBu3BnEACQuiqktU4BwzM-xaA@mail.gmail.com> (Eric Sunshine's message of "Sun, 10 Jul 2022 22:41:12 -0400")

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Sun, Jul 10, 2022 at 10:00 PM Han Xin <chiyutianyi@gmail.com> wrote:
>> On Sun, Jul 10, 2022 at 4:12 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>> > On macOS High Sierra (10.13), Apple's `clang`[1] complains about missing
>> > braces around initialization of a subobject, which is problematic when
>> > building with `DEVELOPER=YesPlease` which enables `-Werror`:
>> >
>> >     builtin/unpack-objects.c:388:26: error: suggest braces around
>> >         initialization of subobject [-Werror,-Wmissing-braces]
>> >             git_zstream zstream = { 0 };
>> >
>> > [1]: `cc --version` => "Apple LLVM version 10.0.0 (clang-1000.10.44.4)"
>> > -       git_zstream zstream = { 0 };
>> > +       git_zstream zstream = {{ 0 }};
>>
>> Not a comment, just wondering, when should I use "{ { 0 } }" and when
>> should I use "{ 0 }"?
>>
>> I didn't get the error with "Apple clang version 13.0.0
>> (clang-1300.0.29.30)",  because it's
>> a higher version ?
>
> I don't have a good answer. More modern `clang` versions don't seem to
> complain about plain old `{0}` here, but the older `clang` with which
> I'm stuck does complain.

I think, from the language-lawyer perspective, "{ 0 }" is how we
should spell these initialization when we are not using designated
initializers, even when the first member of the struct happens to be
a struct.

The older clang that complains at you is simply buggy, and I think
we had the same issue with older sparse.


  reply	other threads:[~2022-07-11  4:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-10  8:11 [PATCH] unpack-objects: fix compilation warning/error due to missing braces Eric Sunshine
2022-07-11  2:00 ` Han Xin
2022-07-11  2:41   ` Eric Sunshine
2022-07-11  4:38     ` Junio C Hamano [this message]
2022-07-12  6:28       ` Eric Sunshine
2022-07-12  6:41         ` Ævar Arnfjörð Bjarmason
2022-07-12  7:13           ` Eric Sunshine
2022-07-12  7:23             ` Jeff King
2022-07-12  7:33               ` Eric Sunshine
2022-07-12  9:16               ` Ævar Arnfjörð Bjarmason
2022-07-14 21:54                 ` Jeff King
2022-07-15  8:20                   ` Ævar Arnfjörð Bjarmason
2022-07-12 14:46             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq7d4kp8l6.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=chiyutianyi@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).