From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>,
git@vger.kernel.org, "Eric Sunshine" <sunshine@sunshineco.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH] merge-file: fix build warning with gcc 4.8.5
Date: Fri, 29 Jul 2022 15:53:53 -0400 [thread overview]
Message-ID: <YuQ60ZUPBHAVETD7@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqbkt7api9.fsf@gitster.g>
On Fri, Jul 29, 2022 at 08:48:46AM -0700, Junio C Hamano wrote:
> I think the concensus was that we should squelch the false warning
> on older compilers with -Wno-missing-braces, but then the discussion
> has stalled by a suggestion to introduce a way to detect older
> compilers that is different from how we do so at the same time, and
> went nowhere.
>
> Hopefully we can add a simple -Wno-* without waiting for whole
> config.mak thing getting revamped this time?
Perhaps this?
-- >8 --
Subject: [PATCH] config.mak.dev: squelch -Wno-missing-braces for older gcc
Versions of gcc prior to 4.9 complain about an initialization like:
struct inner { int x; };
struct outer { struct inner; };
struct outer foo = { 0 };
and insist on:
struct outer foo = { { 0 } };
Newer compilers handle this just fine. And ignoring the window even on
older compilers is fine; the resulting code is correct, but we just get
caught by -Werror.
Let's relax this for older compilers to make developer lives easier (we
don't care much about non-developers on old compilers; they may see a
warning, but it won't stop compilation).
Signed-off-by: Jeff King <peff@peff.net>
---
Tested on a debian jessie chroot using gcc-4.8 and 4.9. Though note that
you also need to manually specify -std=gnu99 to get it to work at all
with those compilers these days! So I kind of wonder if it's even worth
catering to their warnings automatically.
config.mak.dev | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/config.mak.dev b/config.mak.dev
index 335efd4620..b9878a4994 100644
--- a/config.mak.dev
+++ b/config.mak.dev
@@ -59,9 +59,13 @@ endif
# uninitialized warnings on gcc 4.9.2 in xdiff/xdiffi.c and config.c
# not worth fixing since newer compilers correctly stop complaining
+#
+# Likwise, gcc older than 4.9 complains about initializing a
+# struct-within-a-struct using just "{ 0 }"
ifneq ($(filter gcc4,$(COMPILER_FEATURES)),)
ifeq ($(filter gcc5,$(COMPILER_FEATURES)),)
DEVELOPER_CFLAGS += -Wno-uninitialized
+DEVELOPER_CFLAGS += -Wno-missing-braces
endif
endif
--
2.37.1.804.g1775fa20e0
next prev parent reply other threads:[~2022-07-29 19:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-29 9:05 [PATCH] merge-file: fix build warning with gcc 4.8.5 Đoàn Trần Công Danh
2022-07-29 15:48 ` Junio C Hamano
2022-07-29 19:53 ` Jeff King [this message]
2022-07-29 19:54 ` Jeff King
2022-07-29 20:48 ` Eric Sunshine
2022-07-29 21:00 ` Jeff King
2022-07-29 21:23 ` Junio C Hamano
2022-07-30 0:19 ` Đoàn Trần Công Danh
2022-07-30 1:40 ` Jeff King
2022-07-30 1:46 ` brian m. carlson
2022-07-30 23:50 ` Jeff King
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=YuQ60ZUPBHAVETD7@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=avarab@gmail.com \
--cc=congdanhqx@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--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