MISRA Discussion Forums
Seeking Clarification for Required Rule 0-1-8 - 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.0 Language independent issues (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=129)
+---- Thread: Seeking Clarification for Required Rule 0-1-8 (/showthread.php?tid=538)



Seeking Clarification for Required Rule 0-1-8 - gs - 20-06-2008

MISRA C++ 0-1-8 (Required) states, "All functions with void return type shall have external side effect(s)." Quoting the rationale:
Quote: A function which does not return a value and which does not have external side effects will only consume time and will not contribute to the generation of any outputs, which may not meet developer expectations. The following are examples of external side effects:
• Reading or writing to a file, stream, etc.;
• Changing the value of a non local variable;
• Changing the value of an argument having reference type;
• Using a volatile object;
• Raising an exception.

So, what about this function:
Code:
void f()
    {
    try {
        throw 3;
    }
    catch( int )
        {}
    }

The above function raises an exception. However, as We see, the catch handler processes the exception within the same function and does "not contribute to the generation of any outputs". In such a case, does the function meet the requirements of 0-1-8?


Re: Seeking Clarification for Required Rule 0-1-8 - misra cpp - 11-10-2016

A valid point.

A future edition or Technical Corrigendum will modify the exception to 'Raises an exception that transfers control outside the current function'