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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
But a warning that says "this resource might be leaked, you should add
try-catch to clean it up" would be suggesting awful code that goes against all
good design guidance.

A more useful warning would be to warn "about local variables assigned via
operator new or operator new[]" period. Forget the "but then are not freed in
an exception handling clause in case of an exception" part completely.

We should not be adding warnings to say "fix this fragile, manual memory
mangement code by adding fragile, manual error handling code".

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#r11-avoid-calling-new-and-delete-explicitly
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#r12-immediately-give-the-result-of-an-explicit-resource-allocation-to-a-manager-object
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#r20-use-unique_ptr-or-shared_ptr-to-represent-ownership

Reply via email to