[LLVMbugs] [Bug 17290] New: -Wsometimes-uninitialized and -Wconditional-uninitialized give suboptimal fixit with 'bool' variables

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 19 11:21:51 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=17290

            Bug ID: 17290
           Summary: -Wsometimes-uninitialized and
                    -Wconditional-uninitialized give suboptimal fixit with
                    'bool' variables
           Product: new-bugs
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: sean at rogue-research.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11239
  --> http://llvm.org/bugs/attachment.cgi?id=11239&action=edit
repro case

Consider these two warnings:

---------------------
/Users/sean/external/CMake/Utilities/cmcurl/multi.c:928:13: warning: variable
'protocol_connect' may be uninitialized when used here
[-Wconditional-uninitialized]
        if(!protocol_connect) {
            ^~~~~~~~~~~~~~~~
/Users/sean/external/CMake/Utilities/cmcurl/multi.c:766:24: note: initialize
the variable 'protocol_connect' to silence this warning
  bool protocol_connect;
                       ^
                        = '\0'
---------------------

and


---------------------
test.c:8:7: warning: variable 'foo' is used uninitialized whenever 'if'
condition is false [-Wsometimes-uninitialized]
  if (random() % 2)
      ^~~~~~~~~~~~
test.c:13:7: note: uninitialized use occurs here
  if (foo)
      ^~~
test.c:8:3: note: remove the 'if' if its condition is always true
  if (random() % 2)
  ^~~~~~~~~~~~~~~~~
test.c:7:11: note: initialize the variable 'foo' to silence this warning
  bool foo;
          ^
           = 0
---------------------


This is with trunk: "clang version 3.4 (trunk 191016)"

In both cases, it would be better if the fixit suggested using 'false' instead
of '\0' or '0' since the variable in question is a 'bool'.  See attached
trivial test case.

-- 
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/b324218f/attachment.html>


More information about the llvm-bugs mailing list