Re: Sparse not supporting kzalloc_obj() and friends

Al Viro <[email protected]> Wed, 25 Feb 2026 03:51:44 +0000
Newsgroups org.kernel.vger.linux-sparse
Message-ID <20260225035144.GB2924820@ZenIV>
On Mon, Feb 23, 2026 at 08:35:40AM -0800, Linus Torvalds wrote:

> instead, with a dummy empty argument to make the gcc ## trick work.
> It's smaller and denser, so it's actually superior in that sense, even
> if it feels a bit less natural than the __VA_OPT__ model.
> 
> Ricardo, can you verify that that trick works for you?
> 
> Al, comments?

I'll resurrect that branch and post it - hopefully would get something
usable by the weekend.  The main stumbling point had been getting
the interplay with side effects of expansion right - both the __COUNTER__
mess (gccism, with nothing resembling a clear semantics) *and*
the possibility of failure in expansion that had been attempted for no
reason.  Example of the latter:

#define A(X) X
#define B A(
#define Z(X,...) __VA_OPT__(X)
Z(B)

Use of Z obviously has empty vararg (not just after expansion - there's
nothing to expand).  So that __VA_OPT__(X) in its body should be
expanded to an empty token list, _without_ ever expanding the token
list (X) under __VA_OPT__.

Attempt to expand it would fail - it gets to A(, i.e. to use of
a function-like macro with unterminated argument list.

C23 is pretty clear about *not* trying to expand X in that example;
clang handles it correctly, gcc fails.  Reported to gcc bugzilla,
got pretty much no response, then got sidetracked ;-/