[llvm-bugs] [Bug 33982] New: -Wconditional-uninitialized false-positive

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 28 12:37:15 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33982

            Bug ID: 33982
           Summary: -Wconditional-uninitialized false-positive
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org

Code:
void foo();
void bar() {
  int u;
  for (int i = 0; i < 4; i++) {
    if(i == 0)
      u = 0;

    if(u != 0)
      bar();

    u++;
  }
}

Output:
8 : <source>:8:8: warning: variable 'u' may be uninitialized when used here
[-Wconditional-uninitialized]
    if(u != 0)
       ^
3 : <source>:3:8: note: initialize the variable 'u' to silence this warning
  int u;
       ^
        = 0


However i think it should be pretty clear that `u` will be initialized on the
first iteration, so uninitialized `u` will never be read.

Or is this expected and a duplicate of
https://bugs.llvm.org/show_bug.cgi?id=18709 ?

-- 
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/20170728/9249171f/attachment.html>


More information about the llvm-bugs mailing list