Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!sdrc!scjones From: scjones@sdrc.UUCP (Larry Jones) Newsgroups: comp.lang.c Subject: Re: More NULL questions Message-ID: <852@sdrc.UUCP> Date: 11 Oct 89 22:07:24 GMT References: <5950001@hpldola.HP.COM> <443@shodha.dec.com> <903@abvax.UUCP> <448@shodha.dec.com> Organization: Structural Dynamics Research Corp., Cincinnati Lines: 33 In article <448@shodha.dec.com>, devine@shodha.dec.com (Bob Devine) writes: > In article <903@abvax.UUCP>, aep@ivan (Alex E. Pensky) writes: > > Even if pointers and integers are the same size and have the same > > representation, you are still in trouble if your compiler passes int > > parameters and pointer parameters via different mechanisms. In such > > a case, omitting both the prototype and the cast will mean that the *entire* > > parameter list will be received incorrectly by my_func(). > > Yes, such compilers exist, and yes, I have been bitten by one after > > forgetting the casts. > > What different mechanisms? C only supports call-by-value for > parameters (I'm ignoring the special casing of arrays here). How > can pointers be passed differently than ints? It sounds like you > used a broken compiler. It's not call-by-value vs something else, it how you *do* the call-by-value. For example, a compiler could choose to pass three separate arguments lists: one containing the integer parms, one containing the floats, and the third containing the pointers. This is a perfectly valid implementation where passing an incorrectly typed argument can screw up all the following parameters rather than just the erroneous one. "But," I hear you cry, "why would anyone ever implement anything so stupid?!?" Well, start thinking about putting those parameter lists in registers rather than memory, and it should be obvious. ---- Larry Jones UUCP: uunet!sdrc!scjones SDRC scjones@SDRC.UU.NET 2000 Eastman Dr. BIX: ltl Milford, OH 45150-2789 AT&T: (513) 576-2070 "I have plenty of good sense. I just choose to ignore it." -Calvin