AutosarC++19_03-A15.3.5¶
A class type exception shall be caught by reference or const reference
Required inputs: IR
Catching exceptions by value will lead to object slicing when the thrown exception inherits from the exception type specific in the catch clause. Catch exceptions by reference to allow for polymorphism, and to avoid unnecessary copies.
Example
try
{
throw MyException(args);
}
catch (const MyException& ex)
{
...
}
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
catch_without_reference |
A class type exception shall always be caught by reference. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
only_class_types¶
only_class_types : bool = True