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: 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.int func(void) { ... return; /* no return expression - undefined */ } |