``++throw(NULL)++`` is equivalent to ``++throw(0)++``, and is therefore caught by an integer handler. However, since ``++NULL++`` is typically used in the context of pointers, developers may expect it to be caught by a pointer-to-type handler. Thus to avoid confusion, zero should be thrown instead of ``++NULL++``.


== Noncompliant Code Example

----
try
{
  throw ( NULL ); // Noncompliant
}
catch ( int32_t i ) // NULL exception handled here
{
  // ...
}
catch ( const char_t * ) // Developer may expect it to be caught here
{
  // ...
}
----


== Compliant Solution

----
try
{
  throw ( 0 );
}
catch ( int32_t i )
{
  // ...
}
catch ( const char_t * )
{
  // ...
}
----


== See

* MISRA {cpp}:2008, 15-1-2


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
