On Tue, Sep 13, 2016 at 08:45:25PM -0400, David Malcolm wrote: > We warn about uses of uninitialized variables from the middle end, via > warn_uninit. > > This patch adds the ability for such warnings to contain fix-it hints, > showing the user how to zero-initialize the relevant variables. > Naturally this is highly frontend-dependent, so the patch adds a langhook: > LANG_HOOKS_GET_UNINITIALIZED_DECL_FIX to allow the frontend to optionally > provide a fragment of text to be inserted after the decl. > > This is implemented for the C and C++ frontends, for a subset of types, > falling back to not emitting a hint if it's not clearly correct to do so. > The precise text varies with the type e.g. "0" vs "0.0f" vs "0.0" vs "false" > vs "NULL".
Is this warning really a good candidate for a fixit? it doesn't seem at all clear to me that zero initialize the variable is generally the right way to fix the warning. It may well be that it is uninitialized because control flow is incorrect, or that 0 is a valid value and it would be better to initialize with something else that is clearly bogus. Trev