[LLVMbugs] [Bug 15032] New: False positive: Dereference of null pointer

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jan 22 04:28:37 PST 2013


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

             Bug #: 15032
           Summary: False positive: Dereference of null pointer
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: ofv at wanadoo.es
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The code below triggers this warning with clang -r171239 (built with g++ 4.7.2
on Kubuntu x86_64):

$ clang++ --analyze -c csa.cpp
csa.cpp:13:26: warning: Dereference of null pointer
  items[cursor].refCount += 1;
  ~~~~~~~~~~~~~~~~~~~~~~~^~~~


#include <vector>

struct Item {
  Item() : refCount(0) {}
  int refCount;
};

std::vector<Item> items;

void foo() {
  items.push_back(Item());
  std::size_t cursor = items.size() - 1;
  items[cursor].refCount += 1;
}

-- 
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.



More information about the llvm-bugs mailing list