Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If control reaches the closing curly brace (}) of a nonvoid function without evaluating a return statement, using the return value of the function call causes undefined behavior. See undefined behavior 88 in Annex J.2 of the C Standard.

This rule is related to MSC01-C. Strive for logical completeness because both practices are intended to ensure that programs properly handle all possible conditions.

...

In this noncompliant code example, control reaches the end of the checkpass() function when the two strings passed to strcmp() are not equal. This leads to undefined behavior, and various compilers generate code equivalent to the checkpass() function, returning various values when no return statement is executed in checkpass().

...

Noncompliant Code Example

In this noncomplaint noncompliant code example, control reaches the end of the the getlen() function when input does not contain the integer delim. Because the potentially undefined return value of getlen is later used as an index into an array, a buffer overflow may occur.

...

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

MSC37-C

high

unlikely

low

P9

L2

Related Guidelines

...

 

...