[LLVMbugs] [Bug 17290] -Wsometimes-uninitialized and -Wconditional-uninitialized give suboptimal fixit with 'bool' variables
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Sep 19 16:04:23 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17290
David Blaikie <dblaikie at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |dblaikie at gmail.com
Resolution|--- |WORKSFORME
--- Comment #3 from David Blaikie <dblaikie at gmail.com> ---
Works for me:
$ cat bool.c
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
bool foo;
if (random() % 2)
{
foo = true;
}
if (foo)
printf ("Hello");
return 0;
}
blaikie at blaikie:~/dev/scratch$ clang++-tot -Weverything bool.c
clang-3.3: warning: treating 'c' input as 'c++' when in C++ mode, this behavior
is deprecated
bool.c:8:7: warning: variable 'foo' is used uninitialized whenever 'if'
condition is false [-Wsometimes-uninitialized]
if (random() % 2)
^~~~~~~~~~~~
bool.c:13:7: note: uninitialized use occurs here
if (foo)
^~~
bool.c:8:3: note: remove the 'if' if its condition is always true
if (random() % 2)
^~~~~~~~~~~~~~~~~
bool.c:7:11: note: initialize the variable 'foo' to silence this warning
bool foo;
^
= false
1 warning generated.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130919/f515e55f/attachment.html>
More information about the llvm-bugs
mailing list