llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.05k stars 11.98k forks source link

False memory leak report involving self-deleting object #35638

Open llvmbot opened 6 years ago

llvmbot commented 6 years ago
Bugzilla Link 36290
Version 6.0
OS Linux
Attachments Example code that generates false memory leak report
Reporter LLVM Bugzilla Contributor

Extended Description

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: https://pocoproject.org/docs/Poco.AutoPtr.html

I believe the same issue in the static analyzer causes memory leak and null-pointer dereference warnings when using Poco::AutoPtr.

llvmbot commented 6 years ago

assigned to @devincoughlin