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

SR:  10.1#4

Synopsis:A function return expression must be compatible with its implicitly or explicitly defined type. If a function has a non-void return type, then it must contain only com-patible return statements
Language:C
Severity Level:3
Category:EXTERNAL DECLARATIONS


Description:
Justification This leads to undefined behaviour when the function is used.

Example:

float func(void)
{
... /* no return statement */
}

Example:

float func(void)
{
return;	/* no return expression - undefined*/
}

Example:

int func(void)
{
...
return;	/* no return expression - undefined */
}	
Note that this also includes main(), which should contain a return int-expression. The use of the standard function exit() is subject to both implementation defined and undefined behaviour.