It is undefined behaviour if a function has different exception-specifications in different translation units.


== Noncompliant Code Example

----
// Translation unit A
void foo( ) throw ( const char_t * ) {
  throw "Hello World!";
}

// Translation unit B
// foo declared in this translation unit with a different exception
// specification
extern void foo ( ) throw ( int32_t ); // Noncompliant - different specifier
void b ( ) throw ( int32_t ) {
  foo ( ); // The behaviour here is undefined.
}
----


== Compliant Solution

----
// Header for translation unit A
extern void foo ( ) throw ( const char_t * );

// Translation unit A
void foo( ) throw ( const char_t * ) { 
  throw "Hello World!"; 
}

// Translation unit B 
#include "A.h"
void b ( ) throw ( const char_t * ) { 
  foo ( );
}
----


== See

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


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

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