void casts; and C definition question

Sam Kendall kendall at wjh12.UUCP
Wed Oct 5 15:13:32 AEST 1983


	The language should *not* guarantee that calling a function
	without having properly declared the type of the function's
	return value should work, because not all implementations can
	guarantee this.  If pointers and "int"s are different sizes...
	if you don't say "char *malloc()" or whatever you are
	*guaranteed* to lose.

	Guy Harris

You're absolutely right.  In my news item I was referring only to cases
in which the function is defined to return some type, possibly a
structure, but not declared (in another file) to do so, AND the return
value in that file is ignored; and to the language definition issues
raised by such examples.  But I didn't make this distinction clear in my
news item.

An example of what I mean:
	File "a.c":	struct a f()
			{
				...
			}

	File "b.c":	/* no declaration of f() */
			...
				f();	/* call to f, return value ignored */
			...
This example will fail on those machines which use a hidden first argument
to implement structure returning.  But this same lack of declaration is
common for functions which return something other than structures, functions
whose return values are often ignored anyway, such as strcpy().  My question,
then, is what should be guaranteed for such things.

Along these lines, I'd like to see a lint(1) option to warn about default
function and formal parameter declarations, even though they are part of the
language.

	Sam Kendall			{allegra,ihnp4}!wjh12!kendall
	Delft Consulting Corporation	  decvax!genrad!wjh12!kendall



More information about the Comp.lang.c mailing list