...
In this noncompliant code example, if the value 0
is passed, control will flow off the end of the function, resulting in an implicit return and undefined behavior:
Code Block | ||||
---|---|---|---|---|
| ||||
#include <cstdlib> [[noreturn]] void f(int i) { if (i > 0) throw "Received positive input"; else if (i < 0) std::exit(0); } |
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
MSC55-CPP | Medium | Unlikely | Low | P2 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Clang |
| -Winvalid-noreturn |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
Bibliography
[ISO/IEC 14882-2014] | 7.6.3, "Noreturn Attribute" |
...