TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C++ Coding Standard

Rule:  ERR#005Checked automatically with code checker

Synopsis:Check for all errors reported from functions
Severity Level:6
Category:Error Handling


If an error reported this way is ignored, there is no easy way of knowing what eventually made the program crash. It seems natural to check status values returned from functions, but in reality there are huge amounts of code written that does not do these checks. The fact that status values can be ignored by the programmer is one of the reasons to why exception handling in most cases is a better way of reporting errors.


// create socket
int socketfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (socketfd < 0) // check status value
   // ...

Using (void) to cast-away the return value is allowed.

(void) FunctionWithReturnValue(); 

Literature References:
ISC++ Rec. 12.1