rspec/rules/S1037/cfamily/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

78 lines
1.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

== Why is this an issue?
If an exception is thrown when constructing the exception object, or when evaluating the assignment expression that initializes the exception object, it is that exception that propagates in preference to the one that was about to be thrown. This may be inconsistent with developer expectations.
=== Noncompliant code example
[source,cpp]
----
// construction of E2 causes an exception to be thrown
class E2
{
public:
E2 ( )
{
throw 10;
}
};
try
{
if ( ... )
{
throw E2 ( ); // Non-compliant int exception thrown when constructing the E2 object
}
}
----
=== Compliant solution
[source,cpp]
----
class E
{
public:
E ( ) { } // Assume constructor cannot cause an exception
};
try
{
if ( ... )
{
throw E ( ); // Compliant no exception thrown when constructing the object
}
}
----
== Resources
* MISRA {cpp}:2008, 15-1-1
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
An exception could be thrown during construction of "xxx".
'''
== Comments And Links
(visible only on this page)
=== on 14 Oct 2014, 17:56:36 Ann Campbell wrote:
\[~samuel.mercier] please correct the following
* 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
endif::env-github,rspecator-view[]