https://bugs.llvm.org/show_bug.cgi?id=43717
Richard Smith <[email protected]> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Richard Smith <[email protected]> ---
This is working as intended.
-Wuninitialized warns on cases where a particular use of a variable is only
reachable in cases where the variable is uninitialized. (So either that use of
the variable is unreachable, or you have a use-uninitialized bug.)
-Wsometimes-uninitialized warns on cases where a particular branch always
results in an uninitialized use whenever it's taken. (So either that branch can
never be taken in that direction, or you have a use-uninitialized bug.)
Under the assumption that you have no dead code, both warnings have zero false
positives.
If instead you want a warning with fewer false negatives (but that instead has
false positives), you can use -Wconditional-uninitialized. That will warn
whenever we see a use of a variable and we can find any path to that variable
that didn't initialize it. (This has false positives if the path that we find
is actually impossible -- for instance, if it contains two branches on the same
value and requires them to go in different directions.)
-Wconditional-uninitialized does warn on this code:
<stdin>:20:16: warning: variable 'status' may be uninitialized when used here
[-Wconditional-uninitialized]
return status;
^~~~~~
<stdin>:4:19: note: initialize the variable 'status' to silence this warning
int status;
^
= 0
(You can also use -Weverything to find out whether clang has a warning for a
particular construct.)
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs