[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250502020534.GU2023217@ZenIV>
Date: Fri, 2 May 2025 03:05:34 +0100
From: Al Viro <viro@...iv.linux.org.uk>
To: Nathan Chancellor <nathan@...nel.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.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 06:24:49PM -0700, Nathan Chancellor wrote:
> > How long has that been valid? Because this is certainly new to the
> > kernel, and sparse does complain about this initializer.
>
> As you noted, brace initialization for scalars appears to always be
> valid (at least in my testing) but as Al points out, empty braces for
> scalars is only supported in GCC 13+ and Clang 17+ (I think [1] was the
> clang commit), so that is not going to fly...
>From some digging around it looks like
* {} for compounds had been an extension for quite a while
* C++11 got it into standard, with semantics defined as "same
value you get for static-duration variables of that type without an
explicit initializer". For scalar types as well, with the same
semantics.
* On C side that happened (again, with scalar types allowed)
in 2022; N2912 is the first draft with that change already merged,
N2913 is the corresponding editor's report, saying that change in question
(N2900) got merged in January/February virtual meeting.
IOW, C23 has it, no previous versions do. For C17 this syntax
is an error, and AFAICS you need at least -std=c2x or -std=gnu2x to have
it acceptable.
We can make sparse accept it (either unconditionally or with sufficient
-std in arguments), but that won't do a damn thing for cc(1). Does
clang (any version) really accept it with -std=gnu11?
Powered by blists - more mailing lists