MISRA C++:2008 Rule 0-1-7
The value returned by a function having a non- void return type that is not an overloaded operator shall always be used
Description
Rule Definition
The value returned by a function having a non- void return type that is not an overloaded operator shall always be used.
Rationale
The unused return value might indicate a coding error or oversight.
Overloaded operators are excluded from this rule because their usage must emulate built-in operators which might not use their return value.
If you want to deliberately ignore the return value of a function, cast the return value to void
.
Polyspace Implementation
The checker flags functions with non-void
return if the return
value is not used or not explicitly cast to a void
type.
The checker does not flag the functions memcpy
,
memset
, memmove
,
strcpy
, strncpy
, strcat
,
strncat
because these functions simply return a pointer to
their first arguments.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Language Independent Issues |
Category: Required |
Version History
Introduced in R2013b