MISRAC++2008-15-3-1 (C++ only)
In this section:
Synopsis
(Required) Exceptions shall be raised only after start-up and before termination of the program.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
There are exceptions thrown without a handler in some call paths that lead to that point. This check is identical to THROW-static.
Coding standards
This check does not correspond to any coding standard rules.
Code examples
The following code example fails the check and will give a warning:
class C {
public:
C() { throw (0); } // Non-compliant – thrown before main starts
~C() { throw (0); } // Non-compliant – thrown after main exits
};
// An exception thrown in C's constructor or destructor will
// cause the program to terminate, and will not be caught by
// the handler in main
C c;
int main( ... )
{
try {
// program code
return 0;
}
// The following catch-all exception handler can only
// catch exceptions thrown in the above program code
catch ( ... ) {
// Handle exception
return 0;
}
}
The following code example passes the check and will not give a warning about this issue:
class C {
public:
C() { } // Compliant – doesn't throw exceptions
~C() { } // Compliant – doesn't throw exceptions
};
C c;
int main( ... )
{
try {
// program code
return 0;
}
// The following catch-all exception handler can only
// catch exceptions thrown in the above program code
catch ( ... ) {
// Handle exception
return 0;
}
}