MISRA Discussion Forums
std::exception is not a catch-all - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: AUTOSAR C++:2014 rules (https://forum.misra.org.uk/forumdisplay.php?fid=185)
+--- Thread: std::exception is not a catch-all (/showthread.php?tid=1604)



std::exception is not a catch-all - kent.dorfman766 - 13-03-2022

This is a catch-all

try {;} catch(...) {;}

This is not

try {;} catch(std::exception&) {;}

Our validation tool incorrectly triggers the second case as an embedded catch-all violation in a submodule.

Anyone care to debate?

My take is that the rule checker was implemented by python/java folks who think c++ follows the concept of a base exception class.  It does not, since in c++ any type can be an exception parameter.

FWIW, my design heavily leverages c++ shared library .so inclusions which violate autosar eight from sunday even without the erroneous flag.


RE: std::exception is not a catch-all - misra cpp - 22-03-2022

As currently written A15-3-4  regards both  catch(...)  and  catch(std::exception&)  as 'catch-all's

Options © and (d) of the headline would allow the use of a catch-all in a function other than 'main' or a thread entry, but these are completely undecidable. Your analysis tool is therefore at liberty to raise a violation.

Currently, we are not expecting this rule to appear in the next version of MISRA C++