[gnu.gcc.bug] spurious argument mismatch message?

drf@SUN.COM (David Fuchs) (10/11/88)

The following file, compiled with no flags, with GNU-CC version 1.28, gives
the error message:

          foo.c:5: argument `parm' doesn't match function prototype

which appears to be spurious.  Perhaps there is some question about the
what it means to use function prototypes even when the function itself
is declared with "old" syntax; I haven't looked at the standard, but other
compilers seem happy to accept this sort of thing.

Thanks for all the wonderful stuff, by the way.
	-David Fuchs (late of the TeX project, now "frame!drf"@sun.com )

------------------------------------------------------------------------
void foo(short); /* Prototype */

void foo(parm) /* Actual */
short parm;
{
}

drh@notecnirp.Princeton.EDU (Dave Hanson) (10/12/88)

In article <8810102002.AA19547@troy.frame.com> frame!troy!drf@SUN.COM (David Fuchs) writes:
	The following file, compiled with no flags, with GNU-CC version 1.28, gives
	
	          foo.c:5: argument `parm' doesn't match function prototype
	
	which appears to be spurious.  Perhaps there is some question about the
	what it means to use function prototypes even when the function itself
	is declared with "old" syntax;

	void foo(short); /* Prototype */
	
	void foo(parm) /* Actual */
	short parm; {}

this isn't a spurious error; it's correct.
the problem is that the definition is given in `old-style'.
hence, default argument promotions apply, which cause actual
arguments to be promoted to int. thus, the `inferred prototype'
given by the definition is `void foo(int)', which conflicts
with the prototype given explicitly.

mcgrath@tully.Berkeley.EDU (Roland McGrath) (10/14/88)

When a function is defined with traditional syntax:
	void func(x)
	short int x; { ... }
The `short int' gets widened to an `int'.

A prototype declaration containing a `short int' argument says that the
argument should not be widened.
--
	Roland McGrath

roland@wheaties.ai.mit.edu, mit-eddie!wheaties.ai.mit.edu!roland