== Why is this an issue?

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


=== Noncompliant code example

[source,cpp]
----
// 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

[source,cpp]
----
// 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 ( );
}
----


== Resources

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


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Correct the thrown exception(s) to match those of the declaration.


'''
== Comments And Links
(visible only on this page)

=== relates to: S822

=== relates to: S927

=== relates to: S928

=== relates to: S1017

=== is related to: S1049

=== is related to: S829

=== is related to: S833

=== on 14 Oct 2014, 18:29:12 Ann Campbell wrote:
\[~samuel.mercier] please correct the following

* There is no message
* Add a See section to the description listing the appropriate MISRA number
* Fill in Applicability.
* Make sure the appropriate MISRA C and MISRA {cpp} fields on the references tab are filled in
* I would not use Maintainability/Understandability for an "undefined behavior" rule. In fact, I doubt Maintainability is applicable to many MISRA rules at all. I would assign this one to reliability, instead

endif::env-github,rspecator-view[]
