[LLVMbugs] [Bug 15987] New: False positive "use of memory after it is freed" involving boost::shared_ptr, libstdc++

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon May 13 16:01:42 PDT 2013


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

            Bug ID: 15987
           Summary: False positive "use of memory after it is freed"
                    involving boost::shared_ptr, libstdc++
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: bugzilla at jwwalker.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Overview:

The static analyzer claims that memory is used after it is freed when I create
a shared_ptr on the stack and push it onto a vector.  This happens when using
libstdc++, not when using libc++.


Steps to reproduce:

Use the static analyzer on the following code, using libstdc++.

-------------------------------
#include <vector>
#include <boost/smart_ptr.hpp>

typedef boost::shared_ptr<int>    sharedData;

typedef std::vector< sharedData >    DataVec;

class SomeImp
{
public:
                    SomeImp()  {}
                    ~SomeImp() {}    
private:
    void            Build();

    DataVec            mData;
};

void    SomeImp::Build()
{
    sharedData meshData( new int );

    mData.push_back( meshData );
}
-------------------------------


Actual results:

warning: Use of memory after it is freed


Expected results:

No warning.


Build date:

clang version 3.4 (trunk 181711)
Target: x86_64-apple-darwin11.4.2
Thread model: posix


Additional information:

I'm using Boost 1.51.0, if that matters.  The whole command line looks like
this:
/opt/bin/clang -x c++ -arch i386 -stdlib=libstdc++ -isysroot
/Applications/Xcode_4.6.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
-mmacosx-version-min=10.7  -I/Volumes/Home/Mercurial/boost_1_51_0 --analyze
/Volumes/Attic/Dependency/Testapp/Testapp/SharedPtr.cpp

-- 
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/20130513/0cae5911/attachment.html>


More information about the llvm-bugs mailing list