[Bug c++/33715] Suggest -Wmemleak warning for C++

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 18 16:54:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33715

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-04-18 16:53:37 UTC ---
(In reply to comment #0)
> I would like to have a warning in C++ that warns about local variables assigned
> via operator new or operator new[], but then are not freed in an exception
> handling clause in case of an exception.

Simple solution: don't do that. Ever.

Then you don't need a compiler warning.

If you insist on writing such code the cppcheck tool can issue the sort of
warning you want (but it gives lots of false positives too).



More information about the Gcc-bugs mailing list