<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 memory leak report involving self-deleting object"
   href="https://bugs.llvm.org/show_bug.cgi?id=36290">36290</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>False memory leak report involving self-deleting object
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jakob.leben@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19836" name="attach_19836" title="Example code that generates false memory leak report">attachment 19836</a> <a href="attachment.cgi?id=19836&action=edit" title="Example code that generates false memory leak report">[details]</a></span>
Example code that generates false memory leak report

The attached example reports a potential memory leak:

$ scan-build-6.0 clang++-6.0 -std=c++14 example.cpp

example.cpp:19:1: warning: Potential leak of memory pointed to by 'p'
}
^

I believe there is no memory leak in this example though.

The example exhibits a pattern sometimes used in smart pointer implementations,
such as Poco::AutoPtr:
<a href="https://pocoproject.org/docs/Poco.AutoPtr.html">https://pocoproject.org/docs/Poco.AutoPtr.html</a>

I believe the same issue in the static analyzer causes memory leak and
null-pointer dereference warnings when using Poco::AutoPtr.</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>