Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!vector!rpp386!jfh From: jfh@rpp386.Dallas.TX.US (The Beach Bum) Newsgroups: comp.lang.c Subject: Re: Undeclared function arguments Summary: Me first ;-) Message-ID: <8058@rpp386.Dallas.TX.US> Date: 18 Oct 88 23:19:52 GMT References: <13168@dhw68k.cts.com> <2686@hound.UUCP> Reply-To: jfh@rpp386.Dallas.TX.US (The Beach Bum) Distribution: na Organization: River Parishes Programming, Dallas TX Lines: 45 In article <2686@hound.UUCP> rkl1@hound.UUCP (K.LAUX) writes: > The reason that 'm' was not declared was that the body of the >function did not reference the variable at all *AND* it was the last >parameter in the formal argument list. Since arguments are pushed on >the stack from *right* to *left*, there was no need to know its size. This is not portable, relevant, or correct. The formal argument `m' has a default type of `m', hence the type and size are known, as a matter of fact. Regardless of `m' being referenced, the type will always default to `int'. The order of arguments on the stack, or even the existance of a stack, is not an issue which is addressed by the language specification. There exists hardware in which a function with two arguments will pass the actual parameters are passed in registers or pre-allocated regions of memory. > It would be a different case if: > > YYBACK (i, m, n) > > and only i and n were referenced because now the compiler would >*have* to know the size of m in order to correctly reference n on the stack. This would be correct if the size of `m' were not set by default to be sizeof (int). If the call were YYBACK (i, m, n) int i; struct foo m; int n; and the size of `m' weren't known, THEN it MIGHT be an issue. However, only structure pointers do not require the size of the underlying structure to be known. Since `m' in this case is not a pointer, this exception does not apply and the above example is illegal. C provides that undeclared formal parameters default to type `int'. This may not be a wonderful idea, but it does cover this situation. -- John F. Haugh II +----Make believe quote of the week---- VoiceNet: (214) 250-3311 Data: -6272 | Nancy Reagan on Richard Stallman: InterNet: jfh@rpp386.Dallas.TX.US | "Just say `Gno'" UucpNet : !killer!rpp386!jfh +--------------------------------------