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: [email protected]
Reporter: [email protected]
CC: [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs