If control reaches the end of a non-void function, using the return value of the function call results in undefined behavior. See also undefined behavior 7 of Appendix J.
This rule is related to rule recommendation MSC01-C. Strive for logical completeness because both rules involve ensuring that programs properly handle all possible conditions.
...
This error is frequently diagnosed by compilers. (See guideline recommendation MSC00-C. Compile cleanly at high warning levels.)
...
This compliant solution changes the interface of getlen()
to store the result in a user-provided pointer and return an error code to indicate any error conditions. The best method for handling this type of error is specific to the application and the type of error. (See guideline recommendation ERR00-C. Adopt and implement a consistent and comprehensive error-handling policy for more on error handling.)
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
MSC37-C | high | unlikely | low | P9 | L2 |
Bibliography
Related Guidelines
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.9.1, "Function definitions" Wiki Markup
Bibliography
...
MSC36-C. Check for alignment of memory space before calling realloc() function 49. Miscellaneous (MSC) MSC38-C. Do not treat as an object any predefined identifier that might be implemented as a macro