Re: [PATCH] [RFC] Initialization of unused function parameters

From: Evgenii Stepanov
Date: Tue Jun 14 2022 - 18:08:59 EST


On Tue, Jun 14, 2022 at 2:45 PM Segher Boessenkool
<segher@xxxxxxxxxxxxxxxxxxx> wrote:
> No such luck: the passing itself already causes UB.
>
> GCC does not warn, it has already optimised the code to what you expect
> by the time this warning is done. If you use -fno-inline it does warn
> for both "c" and "size" (via -Wmaybe-uninitialized).
>
> But it is still UB! All bets are off, no compiler can do any correct
> translation of your program, since there *is none*.

Clang also puts "noundef" attribute on most function arguments in the
frontend, and the optimizer can assume that the inputs are fully
initialized. The diagnostic for this is very imperfect.

What Alex is proposing (the KMSAN option) takes place *after*
inlining, so it will only enforce the "semantically meaningful" case
in Linus's words.