Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!bionet!agate!ucbvax!dog.ee.lbl.gov!elf.ee.lbl.gov!torek From: torek@elf.ee.lbl.gov (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Func Protos with K&R Func Defs Message-ID: <10714@dog.ee.lbl.gov> Date: 7 Mar 91 03:42:34 GMT References: <1991Feb28.021715.18153@athena.mit.edu> <15354@smoke.brl.mil> <1991Mar2.181953.15401@athena.mit.edu> Reply-To: torek@elf.ee.lbl.gov (Chris Torek) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 34 X-Local-Date: Wed, 6 Mar 91 19:42:35 PST In article peter@ficc.ferranti.com (Peter da Silva) writes: >So you're saying that the compiler is not allowed to take advantage of the >prototype information and use (for example) callee saves or special LINK >instructions when calling prototyped functions? This statement is correct (in a strict logical sense), but all the implications it makes are wrong. That is, the statement [compiler treats prototyped functions specially] implies [compiler may not take advantage of...] is true but only because the clause [compiler treats prototyped functions specially] is false. Aside from default promotions, prototyped functions and non-prototyped functions are treated identically. In particular, the compiler make take advantage of special LINK or RET instructions for non-prototyped functions as well as for the prototyped versions. The only special case is varargs functions, which *must* be declared using the new prototype varargs syntax. All other functions may be assumed to take fixed argument lists. In other words, f(fmt, a1, a2, a3, a4, a5) char *fmt; { printf(fmt, a1, a2, a3, a4, a5); } ... f("%d\n", 3); is illegal, because the caller did not supply the proper number and type of arguments. -- In-Real-Life: Chris Torek, Lawrence Berkeley Lab EE div (+1 415 486 5427) Berkeley, CA Domain: torek@ee.lbl.gov