negativ wrote:

> I think this should be an option instead. If there is a global logger in 
> program, it could be used to at least write a warning message that something 
> was caught inside destructor. I believe it's something that people could 
> enforce with this check and disabling such functionality unconditionally is 
> not good IMO.

That's a fair point, but from my perspective, the logic should actually be 
inverted.

Instead of enabling this check by default and requiring users to disable it for 
destructors, the check should be disabled for destructors by default, with an 
option to turn it on if a user explicitly needs it.

My reasoning is that an empty catch block inside a destructor is almost always 
a conscious and deliberate decision. The developer who wrote it likely had a 
very strong reason - for example, the valid concern that even a logging 
function could `throw` a second exception and terminate the program.

IMHO, destructors are critical code paths that are already written with 
heightened attention to their reliability, so we should trust the developer's 
intent by default in this specific context.

https://github.com/llvm/llvm-project/pull/161379
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to