MISRAC++2008-15-1-2
In this section:
Synopsis
(Required) NULL shall not be thrown explicitly.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
Throw of NULL integer constant. This check is identical to THROW-null.
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:
#include <stdlib.h>
void example(void)
{
try {
throw ( NULL ); // Non-compliant
}
catch ( int i ) { // NULL exception handled here
// ...
}
catch ( const char * ) { // Developer may expect it to be caught here
// ...
}
}
The following code example passes the check and will not give a warning about this issue:
#include <stdlib.h>
void example(void)
{
char * p = NULL;
try {
throw ( p ); // Compliant
}
catch ( int i ) {
// ...
}
catch ( const char * ) { // Exception handled here
// ...
}
}