<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - False positive in interprocedural analysis of C++ destructors"
href="http://llvm.org/bugs/show_bug.cgi?id=15715">15715</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>False positive in interprocedural analysis of C++ destructors
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>kremenek@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>timac@timac.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=10331" name="attach_10331" title="Xcode project">attachment 10331</a> <a href="attachment.cgi?id=10331&action=edit" title="Xcode project">[details]</a></span>
Xcode project
The Clang Static Analyzer (checker-273 and Xcode 4.6.1) reports a memory leak
for the following source code.
Steps to reproduce:
1- On 10.8.3 with Xcode 4.6.1, create a new CoreFoundation project with ARC
disabled.
2- Download the attached Xcode project or replace the main.c with a main.cpp
containing the following:
#include <CoreFoundation/CoreFoundation.h>
//
// MyCFString is a wrapper around CFStringRef.
//
class MyCFString
{
public:
static CFStringRef EmptyCFString()
{
static CFStringRef kEmptyCFString = CFSTR("Empty");
return kEmptyCFString;
}
MyCFString()
{
mRef = CFStringRef(CFRetain(EmptyCFString()));
}
~MyCFString()
{
if(mRef != NULL)
CFRelease(mRef);
}
// Adopt doesn't retain the passed CFStringRef
void Adopt(CFStringRef s)
{
if (s != mRef)
{
if(mRef != NULL)
CFRelease(mRef);
mRef = s;
}
}
private:
CFStringRef mRef;
};
int main(int argc, const char * argv[])
{
MyCFString theString;
// Create a CFStringRef
CFStringRef adoptedString = CFStringCreateCopy(kCFAllocatorDefault,
CFSTR("This is not a leak"));
// adoptedString is not retained by Adopt() but the MyCFString destructor
will release adoptedString
theString.Adopt(adoptedString);
return 0;
}
3- Run scan-build /usr/bin/xcodebuild -project InterproceduralBug.xcodeproj
-target "InterproceduralBug" build
Result:
The Clang static analyzer reports a memory leak.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>