[LLVMbugs] [Bug 18394] New: alpha.cplusplus.NewDeleteLeaks false-positive complicated conditions
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Jan 5 16:05:07 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=18394
Bug ID: 18394
Summary: alpha.cplusplus.NewDeleteLeaks false-positive
complicated conditions
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: anton.yartsev at Gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Here is a minimal test that illustrates the problem. My attempts to simplify
the test led to the fact that the leak is not reported. The leak also
disappears if '-std=c++11' option is given to the compiler.
class Iter {
public:
int * _M_current;
Iter(int * __i) : _M_current(__i) { }
int * base() { return _M_current; }
};
bool operator==(Iter __lhs, Iter __rhs)
{ return __lhs.base() == __rhs.base(); }
class vector {
public:
int* _M_start;
int* _M_finish;
public:
Iter begin() const
{ return Iter(_M_start); }
Iter end() const
{ return Iter(_M_finish); }
bool empty() { return begin() == end(); }
};
class raw_ostream {
public:
char *OutBufEnd, *OutBufCur;
int m() {
if (OutBufCur >= OutBufEnd)
return 1;
return 0;
}
};
raw_ostream *v;
vector *interestingSymbols;
class A {
public:
bool f();
~A() {
while (f()) {
interestingSymbols->empty();
interestingSymbols->empty();
interestingSymbols->empty();
}
}
};
void error() {
A *a = new A();
delete a; // false-positive leak!
v->m();
v->m();
v->m();
}
F:\llvm_COMMON\-VS_build-\Debug\bin>clang -cc1
-analyzer-checker=alpha.cplusplus.NewDeleteLeaks -analyze test.cpp
test.cpp:59:3: warning: Potential leak of memory pointed to by 'a'
delete a; // false-positive leak!
^~~~~~~~
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/20140106/29e73ead/attachment.html>
More information about the llvm-bugs
mailing list