certain type mismatches
Mark Brader
msb at sq.uucp
Fri Jul 8 04:10:58 AEST 1988
Chris Torek (chris at mimsy.UUCP), no less, writes:
> > > void execl(char *, ...);
> ... [if it returns at all] it only ever returns -1, so declaring it
> as `int' is somewhat pointless---the value is even less useful than
> that from, e.g., strcpy().
But "function returning int" and "function returning void" are different
types. A compiler might choose to implement calls to these functions
differently. For instance, it could require a function returning int
to push its return value on the stack, and leave the caller to pop it off.
Then if you declare the function type wrong, your stack is trashed.
There may be no such compilers at the moment, but they're certainly within
the rules. int execl() and (void)execl(...); is what you must say.
Incidentally, the (January 1988) ANSI draft's requirement that void *
have the same representation as char * contains a similar defect.
Not only the representation but also the function calling conventions
applicable to the type should have been required to be the same.
I mentioned this in my public comment letter but, judging from the
response I received, I seem to have been misunderstood.
Mark Brader "Strong typing isn't for weak minds; the argument
Toronto 'strong typing is for weak minds' is for weak minds."
utzoo!sq!msb, msb at sq.com -- Guy Harris
More information about the Comp.lang.c
mailing list