...
The currently handled exception is rethrown if control reaches the end of a handler of the function-try-block of a constructor or destructor.
Consequently, the caught exception will inevitably escape from the SomeClass destructor because it is implicitly rethrown when control reaches the end of the function-try-block handler.
...
Attempting to throw exceptions from destructors or deallocation functions can result in undefined behavior, leading to resource leaks or denial-of-service attacks.
Rule | Severity | LikelihoodRemediation Cost | Detectable | Repairable | Priority | Level |
|---|---|---|---|---|---|---|
DCL57-CPP | Low | Likely | Yes | YesMedium | P6P9 | L2 |
Automated Detection
Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Astrée |
| destructor-without-noexcept delete-without-noexcept | Fully checked | ||||||
| Axivion Bauhaus Suite |
| CertC++-DCL57 | |||||||
| CodeSonar |
| LANG.STRUCT.EXCP.CATCH LANG.STRUCT.EXCP.THROW | Use of catch Use of throw | ||||||
| Helix QAC |
| C++2045, C++2047, C++4032, C++4631 | |||||||
| Klocwork |
| MISRA.DTOR.THROW | |||||||
| LDRA tool suite |
| 453 S | Partially implemented | ||||||
| Parasoft C/C++test |
| CERT_CPP-DCL57-a | Never allow an exception to be thrown from a destructor, deallocation, and swap | ||||||
| Polyspace Bug Finder |
| CERT C++: DCL57-CPP | Checks for class destructors exiting with an exception (rule partially covered) | ||||||
| PVS-Studio |
| V509, V1045 | |||||||
| RuleChecker |
| destructor-without-noexcept delete-without-noexcept | Fully checked |
...