Page tree

Skip to end of metadata
Go to start of metadata

In this section:

Overview

Insure++ checks that each function returns a result consistent with its declared data type, and that a function with a declared return type actually returns an appropriate value.

Additional configuration required

In order for Insure++ to find this error, the suppressEDGWarning off option is required.

CodeDescriptionEnabledReportedPlatform
RETURN_INCONSISTENTFunction has inconsistent return type(error)CompilationWindows/Unix
(level 1)No declaration, returns nothing(error)CompilationWindows/Unix
(level 2)Declared int, returns nothing(tick)CompilationWindows/Unix
(level 3)Declared non-int, returns nothing(tick)CompilationWindows/Unix
(level 4)Returns different types at different statements(tick)CompilationWindows/Unix


Problem

The following code demonstrates an inconsistent return error:

/*
 * File: retinc.c
 */
func() {
	return;
}

Diagnosis During Compilation

[retinc.c:4] **RETURN_INCONSISTENT**
	Function has an inconsistent return type.
>> func() {
  • Line 1: Source line at which the problem was detected.
  • Line 2: Description of the error and the parameters used.

Repair

Correct inconsistent return errors by either adding appropriate declarations or by making the return type consistent with the function declaration.

Adding appropriate declarations
/*
 * File: retinc.c
 */
	void func() {
	return;
}
Consistency
/*
 * File: retinc.c
 */
int func() {
	return 0;
}
  • No labels