<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 "potential leak of an object" with wrapper reset method"
   href="http://llvm.org/bugs/show_bug.cgi?id=15846">15846</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>False positive "potential leak of an object" with wrapper reset method
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>bugzilla@jwwalker.com
          </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=10427" name="attach_10427" title="RetainCountFalsePositive.cpp">attachment 10427</a> <a href="attachment.cgi?id=10427&action=edit" title="RetainCountFalsePositive.cpp">[details]</a></span>
RetainCountFalsePositive.cpp

Overview:

When using a wrapper class that holds a reference-counted Core Foundation
object, the static analyzer reports a potential leak whenever I have the
wrapper take ownership of an object.


Steps to reproduce:

Analyze the attached Mac C++ source file.


Actual results:

"Potential leak of an object" warning.


Expected results:

No warnings.


Build date:

clang version 3.3 (trunk 180561) (llvm/trunk 180467)
Target: x86_64-apple-darwin11.4.2
Thread model: posix


Additional Information:

If I comment out the line "if (ptr_ != p)" in the Reset method, the warning
goes away.  I guess the analyzer is "thinking" that the test might fail, so p
might not be assigned to ptr_.  But I can't see any way that
CFStringCreateWithCString could return a pointer that is already in the ptr_
member.</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>