Misleading statements in Rule 15–1–3. - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18) +--- Forum: MISRA C++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19) +---- Forum: 6.15 Exception handling (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=143) +---- Thread: Misleading statements in Rule 15–1–3. (/showthread.php?tid=553) |
Misleading statements in Rule 15–1–3. - James Widman - 14-07-2008 Hi all, In the Rationale for Rule 15–1–3, we have: Quote:However, syntactically, there is nothing to prevent throw; being used outside a catch handler, where there is no exception object to re-throw. This may lead to an implementation-defined program termination.There are a couple of problems with this. First, it't not quite right to refer to a *place* where an exception object can be re-thrown so much as it is to refer to a *time* when such an object can be re-thrown. Refer to 15.1 except.throw. For example, this program: Code: extern "C" int printf( const char*, ... ); ... yields this output: Code: ::A::A() So the text "where there is no exception object to re-throw" should be changed to something like, "where control could pass at a time when there is no exception object to re-throw". Second, the rationale text ends with, "This may lead to an implementation-defined program termination." When you squint at the standardese in just the right way, this sentence is true: it *may* lead to implementation-defined behavior, but only if the non-libary part of the program does not set a terminate_handler. But given the normative text in 15.5.1 except.terminate, it would be much better to change this sentence to: Quote:If an empty throw is used at a time when there is no exception object to re-throw, std::terminate() is implicitly called. (The stack is not unwound before this call.) Re: Misleading statements in Rule 15–1–3. - misra cpp - 11-10-2016 The wording will be reviewed |