When the call to a function doesn't have any side effect, what is the point of making the call if the results are ignored? In such cases, either
the function call is useless and should be dropped, or the source code doesn't behave as expected.
Noncompliant Code Example
strlen($name); // Noncompliant; "strlen" has no side effect
Compliant Solution
$length = strlen($name);
See
- MISRA C:2012, 17.7 - The value returned by a function having non-void return type shall be used
- CERT, EXP12-C. - Do not ignore values returned by functions
- CERT, EXP12-CPP. - Do not ignore values returned by functions or methods
- CERT, EXP00-J. - Do not ignore values returned by methods