[Bug analyzer/122055] -Wanalyzer-use-of-uninitialized-value false positive with self initialization and no optimizations

vincent-gcc at vinc17 dot net gcc-bugzilla@gcc.gnu.org
Thu Dec 18 00:27:03 GMT 2025


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122055

--- Comment #4 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to David Malcolm from comment #2)
> In https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106155#c12 do you mean a
> line like:
>     int emax = emax;
> ?

Yes.

> I've not seen self-initialization used to suppress "may be used
> uninitialized" in this way before.  Is there a style guide somewhere
> recommending this?

For GCC, this was suggested by Richard Biener in bug 36296 comment 3.

> I confess my first thought on seeing a line like:
> 
>    int i = i;
> 
> is that the compiler ought to issue some kind of warning for it.
> 
> Why not simply initialize it, say to 0 ?

Because this is not needed and may hide bugs and warnings if the code changes
(there should be a way to get a warning if the compiler can prove that the
variable is really uninitialized).


More information about the Gcc-bugs mailing list