[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250502002835.GT2023217@ZenIV>
Date: Fri, 2 May 2025 01:28:35 +0100
From: Al Viro <viro@...iv.linux.org.uk>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Nathan Chancellor <nathan@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Masahiro Yamada <masahiroy@...nel.org>,
Nicolas Schier <nicolas.schier@...ux.dev>,
Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
Bill Wendling <morbo@...gle.com>,
Justin Stitt <justinstitt@...gle.com>, linux-kbuild@...r.kernel.org,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev,
patches@...ts.linux.dev, stable@...r.kernel.org,
Linux Kernel Functional Testing <lkft@...aro.org>,
Marcus Seyfarth <m.seyfarth@...il.com>
Subject: Re: [PATCH 2/2] include/linux/typecheck.h: Zero initialize dummy
variables
On Thu, May 01, 2025 at 04:28:25PM -0700, Linus Torvalds wrote:
> On Thu, 1 May 2025 at 16:00, Nathan Chancellor <nathan@...nel.org> wrote:
> >
> > +({ type __dummy = {}; \
> > + typeof(x) __dummy2 = {}; \
>
> I'm actually surprised that this doesn't cause warnings in itself.
>
> The types in question are not necessarily compound types, and can be
> simple types like 'int'.
>
> The fact that you can write
>
> int x = {};
>
> without the compiler screaming bloody murder about that insanity blows
> my mind, but it does seem to be valid C (*).
>
> How long has that been valid? Because this is certainly new to the
> kernel, and sparse does complain about this initializer.
>
> So honestly, this will just cause endless sparse warnings instead. I
> think disabling this warning for now is likely the right thing to do.
>
> Linus
>
> (*) Yes, the empty initializer is new in C23, but we've used that in
> the kernel for non-scalar objects for a long time.
For scalars it had been flat-out invalid all along - doesn't even
need -Wpedantic for gcc to reject that. I hadn't checked C23, but
older variants all fail on that.
We can force sparse to accept that thing, but I rather wonder if it's
a good idea. Both gcc 12 and clang 14 give hard error with -std=gnu11;
do we really want to bump the minimal versions that much?
Powered by blists - more mailing lists