Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

False memory leak report involving self-deleting object #35263

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR36290
Status NEW
Importance P normal
Reported by Jakob Leben (jakob.leben@gmail.com)
Reported on 2018-02-07 20:49:11 -0800
Last modified on 2018-02-07 20:49:25 -0800
Version 6.0
Hardware PC Linux
CC jakob.leben@gmail.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments example.cpp (203 bytes, text/x-c++src)
Blocks
Blocked by
See also
Created attachment 19836
Example code that generates false memory leak report

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.
Quuxplusone commented 6 years ago

Attached example.cpp (203 bytes, text/x-c++src): Example code that generates false memory leak report