[llvm-bugs] [Bug 26451] New: Spurious use after free warning when using %p

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 3 06:18:42 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26451

            Bug ID: 26451
           Summary: Spurious use after free warning when using %p
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: sitsofe at yahoo.com
                CC: llvm-bugs at lists.llvm.org
        Depends on: 26221
    Classification: Unclassified

Created attachment 15814
  --> https://llvm.org/bugs/attachment.cgi?id=15814&action=edit
C program that demonstrates spurious use after free warning

Description of the problem:
Code that prints the address of a pointer after the memory has been freed
triggers a "Use of memory after it is freed" warning even though the pointer
itself is not dereferenced.

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

Expected results:
No warnings.

Actual results:
# scan-build: Using '/usr/bin/clang' for static analysis
spurious-printf-use-after-free.c:11:2: warning: Use of memory after it is freed
        printf("%p\n", (void *)p);
        ^~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

Additional information:
This problem was identified by Barry Davis of StorMagic.

Version information:
llvm-3.7.0-3.fc23.x86_64
clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-redhat-linux-gnu
Thread model: posix

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160203/9b7709e7/attachment.html>


More information about the llvm-bugs mailing list