Calling functions with incorrect arguments is a common problem in many programs and can often go unnoticed. For example, Insure++ detects the error in the following program in which the argument passed to the function foo in main is an integer rather than a floating point number:

double foo(dd)
	double dd;
{
	return dd + 1.0;
}


main()
{
	printf("Result = %f\n", foo(1)0;
}

Converting this program to ANSI style (for example, with a function prototype for foo makes it correct since the argument passed in main will be automatically converted to double. Insure++ doesn’t report an error in this case.

Insure++ detects several different categories of errors, which you can enable or suppress separately depending on which types of bugs you consider important.

  • Sign errors - Arguments agree in type but one is signed and the other unsigned (for example, int vs. unsigned int).

  • Compatible types - The arguments are different data types that happen to occupy the same amount of memory on the current machine (for example, int vs. long if both are 32-bits). While this error might not cause problems on your current machine, it is a portability problem.

  • Incompatible types - Similar to the example above. Data types are fundamentally different or require different amounts of memory. int vs. long would appear in this category on machines where they require different numbers of bits.

  • No labels