This diagnostic rule is based on the MISRA (Motor Industry Software Reliability Association) software development guidelines.
This diagnostic rule is relevant only for C++.
The analyzer has detected that the throw expression has no operand (rethrowing the active exception) and is not located inside a catch block. Such code may contain an error. A throw; statement outside the explicit syntactic boundaries of a catch handler is a sign of a potential defect. If the code is executed while there are no active exceptions in the program, the std::terminate function will be invoked, causing the program to crash.
The example:
try
{
if (ok)
return ....;
throw;
}
catch (...)
{
}
In this example, the throw expression is executed within the try block, where no exception has yet been caught. Since the exception object for the throw is missing, executing this code results in the std::terminate function invocation.
The fixed code:
try
{
if (ok)
return ...;
throw some_exception(....);
}
catch (...)
{
}
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: