<html>
    <head>
      <base href="https://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 --- - Spurious use after free warning"
   href="https://llvm.org/bugs/show_bug.cgi?id=26221">26221</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Spurious use after free warning
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.8
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>sitsofe@yahoo.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=15677" name="attach_15677" title="C program that demonstrates spurious use after free warning">attachment 15677</a> <a href="attachment.cgi?id=15677&action=edit" title="C program that demonstrates spurious use after free warning">[details]</a></span>
C program that demonstrates spurious use after free warning

Description of the problem:
Code that copies data being pointed at into a new variable which goes on to
then free the original pointer triggers a spurious use after free error.

Steps to reproduce:
1. Compile the attached C program using
scan-build-3.8 cc -O1 spurious-use-after-free.c -c

Expected results:
No warnings.

Actual results:
# scan-build-3.8 cc -O1 spurious-use-after-free.c -c
scan-build: Using '/usr/lib/llvm-3.8/bin/clang' for static analysis
spurious-use-after-free.c:15:5: warning: Use of memory after it is freed
    return item->next; // Flagged as use after free
    ^~~~~~~~~~~~~~~~~
1 warning generated.
scan-build: 1 bug found.
scan-build: Run 'scan-view /tmp/scan-build-2016-01-20-133203-7599-1' to examine
bug reports.

Additional information:
This problem was identified and the reduced test case was produced by Barry
Davis of StorMagic.

Version information:
LLVM packages installed from <a href="http://llvm.org/apt/wily/">http://llvm.org/apt/wily/</a>
Ubuntu clang version 3.8.0-svn257294-1~exp1 (trunk) (based on LLVM 3.8.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin</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>