On Thu, 1 May 2025 at 18:24, Nathan Chancellor nathan@kernel.org wrote:
but '= {0}' appears to work: https://godbolt.org/z/x7eae5vex
If using that instead upsets sparse still, then I can just abandon this change and update the other patch to disable -Wdefault-const-init-unsafe altogether (
The "= { 0 }" form makes sparse unhappy for a different reason:
void *a = { 0 };
makes sparse (correctly) complain about the use of '0' for 'NULL'.
warning: Using plain integer as NULL pointer
and gcc has also finally adopted that warning for braindamage:
warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]
although it's not on by default (and apparently we've never enabled it for the kernel - although we really should).
sparse has complained about this since day one, because I personally find the "plain 0 as NULL" to be a complete BS mistake in the language (that came from avoiding a keyword, not from some "design" reason), and while it took C++ people three decades to figure that out, in the end they did indeed figure it out.
In case anybody wonders why '0' is so broken for NULL, think stdarg.
But also think "Christ people, it's fundamental type safety!!%^%!!"
Linus