git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] merge-file: fix build warning with gcc 4.8.5

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 29, 2022, 20:48 UTC
Message-ID
<CAPig+cSiAEgopj1zwR4kUG=ZLJQrNAVj0P5g4veWYD-ERr=irw@mail.gmail.com>
In-Reply-To
<YuQ60ZUPBHAVETD7@coredump.intra.peff.net>
On Fri, Jul 29, 2022 at 3:53 PM Jeff King <peff@peff.net> wrote:
Show 21 quoted lines
> 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>

Leaving aside for the moment the problem with Apple's oddball invented version numbers for `clang`, should this patch also take older `clang` versions into consideration rather than focusing only on `gcc`? (Of course, `clang` could be dealt with in a separate patch if you'd rather not worry about it here.)

Show 17 quoted lines
> 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
Previous: Jeff KingNext: Jeff King
Message 5 of 11 in “merge-file: fix build warning with gcc 4.8.5”
  1. merge-file: fix build warning with gcc 4.8.5Đoàn Trần Công Danh, Jul 29, 2022
  2. Junio C HamanoJul 29, 2022
  3. Jeff KingJul 29, 2022
  4. Jeff KingJul 29, 2022
  5. Eric SunshineJul 29, 2022
  6. Jeff KingJul 29, 2022
  7. Junio C HamanoJul 29, 2022
  8. Đoàn Trần Công DanhJul 30, 2022
  9. Jeff KingJul 30, 2022
  10. brian m. carlsonJul 30, 2022
  11. Jeff KingJul 30, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.