Details
-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Message:Remove this "throw" clause
-
Highlighting:
-
Default Severity:Critical
-
Impact:High
-
Likelihood:Low
-
Default Quality Profiles:Sonar way
-
Legacy Key:ExceptionSpecificationUsage
-
Covered Languages:C, C++
-
Remediation Function:Constant/Issue
-
Constant Cost:1min
-
Analysis Scope:Main Sources
-
CppCoreGuidelines:E.30
Description
Exception specifications never really provided any advantages in C+. They have been deprecated since C11, and removed since C17 (specification with an exception) and C+20 (empty throw specification). If your code still contains some, you should replace empty throw() specifications, with noexcept and remove any other specifications.
Noncompliant Code Example
void f() throw(); // Noncompliant void g() throw(std::exception); // Noncompliant
Compliant Solution
void f() noexcept; void g();
See
- C++ Core Guidelines E.30 - Don’t use exception specifications
Exceptions
If a derived class overrides a function with a dynamic exception specification, then the derived function is forced to add a compatible exception specification. Such exception specifications are ignored.
Attachments
Issue Links
1.
|
C-Family | RSPEC-5105 |
|
Active | Unassigned |