[cfe-dev] c++-analyzer warning question

Dave Flogeras via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 20 18:05:33 PDT 2016


Hi, I have some code that generates a warning when passed through
c++analyzer and I am wondering if someone can help me understand it.

I have put the code for a toy example here
https://github.com/dflogeras/analyzer

It uses CMake, I am building on (Gentoo) Linux using clang/LLVM 3.7.1 with
GCC-4.9.3 headers.  You can build it by doing the following:
- Install CMake if needed, I'm using 3.5.2
- Clone the repo
- Inside the repo make a build dir for out of tree building, ie.
path/to/analyzer/build
- from within build/ run "CXX=c++-analyzer cmake ..
-DCMAKE_BUILD_TYPE=Release"
- once finished, run make

You'll (hopefully) see it generate the warning like

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/unique_ptr.h:273:4:
warning: Potential memory leak
          return *this;

My question is, is this a proper warning?  Are you not allowed to
implicitly upcast a smart_ptr from the return of operator= ?

Thanks for any help, and sorry for any ignorance.
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160920/36e51e56/attachment.html>


More information about the cfe-dev mailing list