Checksum: 57393 Lines: 27 Path: utzoo!sq!msb From: msb@sq.uucp (Mark Brader) Date: Thu, 7-Jul-88 14:10:58 EDT Message-ID: <1988Jul7.141058.20804@sq.uucp> Newsgroups: comp.lang.c Subject: certain type mismatches References:<6966@cup.portal.com> <1315@ark.cs.vu.nl> <12325@mimsy.UUCP> Reply-To: msb@sq.com (Mark Brader) Organization: SoftQuad Inc., Toronto Chris Torek (chris@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@sq.com -- Guy Harris