It is possible to add the 'try' statement directly after 'while', for example:
class Exception{};
void f(int i)
{
while(i) try { // Non-compliant
//...
} catch(Exception e){
}
}
I think this is non-compliant with the Rule 9.3.1, because 'try' is not a compound statement. However, accordingly to the standard 'try' should be always followed by a compound statement if it is inside a function. This code seems to be clear, so maybe this case could be added as an exception in the future versions of MISRA C++ standard.
class Exception{};
void f(int i)
{
while(i) try { // Non-compliant
//...
} catch(Exception e){
}
}
I think this is non-compliant with the Rule 9.3.1, because 'try' is not a compound statement. However, accordingly to the standard 'try' should be always followed by a compound statement if it is inside a function. This code seems to be clear, so maybe this case could be added as an exception in the future versions of MISRA C++ standard.