[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a0_ruZSMv-kLMY7Jja7wq0K3aNNDviYqQPmN-3UayiHaQ@mail.gmail.com>
Date: Wed, 7 Apr 2021 09:14:29 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Marek BehĂșn <kabel@...nel.org>
Cc: Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
Nathan Chancellor <natechancellor@...il.com>,
Masahiro Yamada <masahiroy@...nel.org>,
Andrew Lunn <andrew@...n.ch>,
Networking <netdev@...r.kernel.org>
Subject: Re: [PATCH kbuild] Makefile.extrawarn: disable -Woverride-init in W=1
On Wed, Apr 7, 2021 at 2:24 AM Marek BehĂșn <kabel@...nel.org> wrote:
>
> The -Wextra flag enables -Woverride-init in newer versions of GCC.
>
> This causes the compiler to warn when a value is written twice in a
> designated initializer, for example:
> int x[1] = {
> [0] = 3,
> [0] = 3,
> };
>
> Note that for clang, this was disabled from the beginning with
> -Wno-initializer-overrides in commit a1494304346a3 ("kbuild: add all
> Clang-specific flags unconditionally").
>
> This prevents us from implementing complex macros for compile-time
> initializers.
I think this is generally a useful warning, and it has found a number
of real bugs. I would want this to be enabled in both gcc and clang
by default, and I have previously sent both bugfixes and patches to
disable it locally.
> For example a macro of the form INITIALIZE_BITMAP(bits...) that can be
> used as
> static DECLARE_BITMAP(bm, 64) = INITIALIZE_BITMAP(0, 1, 32, 33);
> can only be implemented by allowing a designated initializer to
> initialize the same members multiple times (because the compiler
> complains even if the multiple initializations initialize to the same
> value).
We don't have this kind of macro at the moment, and this may just mean
you need to try harder to come up with a definition that only initializes
each member once if you want to add this.
How do you currently define it?
Arnd
Powered by blists - more mailing lists