Linux 6.3-rc3
Linus Torvalds
torvalds at linux-foundation.org
Mon Mar 20 23:41:52 UTC 2023
On Mon, Mar 20, 2023 at 3:06 PM Nathan Chancellor <nathan at kernel.org> wrote:
>
> Right, this seems like a subtle difference in semantics between
> -Wuninitialized between clang and GCC.
I guess it's a bit ambiguous whether it's
"X may be USED uninitialized"
or whether it is
"X may BE uninitialized"
and then depending on how you see that ambiguity, the control flow matters.
In this case, there is absolutely no question that the variable is
uninitialized (since there is no write to it at all).
So it is very clearly and unambiguously uninitialized. And I do think
that as a result, "-Wuninitialized" should warn.
But at the same time, whether it is *used* or not depends on that
conditional, so I can see how it could be confusing and not be so
clear an unambiguous.
On the whole, I do wish that the logic would be "after dead code
removal, if some pseudo has no initializer, it should always warn,
regardless of any remaining dynamic conditoinals".
That "after dead code removal" might matter, because I could see where
config things (#ifdef's etc) would just remove the initialization of
some variable, and if the use is behind some static "if (0)", then
warning about it is all kinds of silly.
Linus
More information about the dri-devel
mailing list