More NULL questions

Larry Jones scjones at sdrc.UUCP
Thu Oct 12 08:07:24 AEST 1989


In article <448 at shodha.dec.com>, devine at shodha.dec.com (Bob Devine) writes:
> In article <903 at abvax.UUCP>, aep at 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 at 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



More information about the Comp.lang.c mailing list