[LLVMbugs] [Bug 21333] New: false positive smartptr release (unique_ptr) in std::<memory>

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Oct 21 16:55:49 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21333

            Bug ID: 21333
           Summary: false positive smartptr release (unique_ptr) in
                    std::<memory>
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: stevemac321 at live.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Not sure anything can be done about this.  If there exists guidance for what
constitutes a false positive, it would be great if someone could point it to
me.  I am running scan-build against libc++ and do not want to spam the bug
database.

Anyway, scan-build flags this:

libcxx/include/memory:2622:9: warning: Use of memory after it is freed
        return __t;
        ^~~~~~~~~~

The code looks like this:
  _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
    {
        pointer __t = __ptr_.first();
        __ptr_.first() = pointer();
        return __t;
    }
It is a reasonable pattern, MSVC STL does basically the same thing.  The
standard says this:
20.8.1.2.5  N3797  [unique.ptr.single.modifiers]

pointer release() noexcept;
1 Postcondition: get() == nullptr.
2 Returns: The value get() had at the start of the call to release.

My env:
clang version 3.6.0 (trunk 217475)
Target: x86_64-unknown-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/20141021/96fd1193/attachment.html>


More information about the llvm-bugs mailing list