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

           Summary: -Wuninitialized false positive
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


>From chrome code:

  bool did_work;
  for (int i = 0; i < 100; ++i) {
    DeletePendingTasks();
    ReloadWorkQueue();
    // If we end up with empty queues, then break out of the loop.
    did_work = DeletePendingTasks();
    if (!did_work)
      break;
  }
  DCHECK(!did_work);



clang complains:


/Volumes/MacintoshHD2/src/chrome-git/src/base/message_loop.cc:168:3: error: use
of uninitialized variable 'did_work' [-Wuninitialized]
  bool did_work;
  ^~~~~~~~~~~~~
In file included from
/Volumes/MacintoshHD2/src/chrome-git/src/base/message_loop.cc:5:
In file included from ../base/message_loop.h:13:
In file included from ../base/message_pump.h:9:
In file included from ../base/ref_counted.h:9:
In file included from ../base/atomic_ref_count.h:15:
In file included from ../base/atomicops.h:139:
In file included from ../base/atomicops_internals_x86_macosx.h:11:
In file included from
/Developer/SDKs/MacOSX10.5.sdk/usr/include/libkern/OSAtomic.h:30:
/Volumes/MacintoshHD2/src/llvm-svn/Release+Asserts/bin/../lib/clang/2.9/include/stdbool.h:37:15:
note: instantiated from:
#define bool  bool
              ^
/Volumes/MacintoshHD2/src/chrome-git/src/base/message_loop.cc:177:3: note:
variable 'did_work' is possibly uninitialized when used here
  DCHECK(!did_work);
  ^~~~~~~~~~~~~~~~~


and suggests adding `= 0`.

Two bugs:
a) The warning is a false positive
b) clang should suggest `= false;`

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to