
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
59 lines
1.4 KiB
Plaintext
59 lines
1.4 KiB
Plaintext
== Why is this an issue?
|
|
|
|
When an exception is thrown, the call stack is unwound up to the point where the exception is to be handled. The destructors for all automatic objects declared between the point where the exception is thrown and where it is to be handled will be invoked. If one of these destructors exits with an exception, then the program will terminate in an implementation-defined manner, potentially yielding unexpected results.
|
|
|
|
|
|
Note that it is acceptable for a destructor to throw an exception that is handled within the destructor, for example within a try-catch block.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,cpp]
|
|
----
|
|
class C1 {
|
|
public: ~C1() {
|
|
throw(42); // Noncompliant - destructor exits with an exception
|
|
}
|
|
};
|
|
|
|
void foo() {
|
|
C1 c; // program terminates when c is destroyed
|
|
throw(10);
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,cpp]
|
|
----
|
|
class C1 {
|
|
public: ~C1() {
|
|
try {
|
|
throw(42); // Compliant - exception will not leave destructor
|
|
} catch (int i) { // int handler
|
|
// Handle int exception throw by destructor
|
|
}
|
|
}
|
|
};
|
|
|
|
void foo() {
|
|
C1 c;
|
|
throw(10);
|
|
}
|
|
----
|
|
|
|
|
|
== Resources
|
|
|
|
* MISRA {cpp}:2008, 15-5-1 - A class destructor shall not exit with an exception.
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|