This diagnostic rule is based on the MISRA (Motor Industry Software Reliability Association) software development guidelines.
This diagnostic rule is relevant only for C.
The _Noreturn specifier prompts the compiler that the function does not return control flow to the caller on any execution path. A violation of this contract leads to undefined behavior (C11, section 6.7.4.8, Annex J2).
Here is an example of erroneous code:
_Noreturn void foo(int x)
{
if (x != 0)
abort();
}
In this example, when the value of the x parameter is zero, foo returns control flow to the caller function. This contradicts the _Noreturn specifier.
The fixed code:
_Noreturn void foo(int x)
{
abort();
}
This diagnostic is classified as:
|
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: