Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ames!ptsfa!hoptoad!academ!uhnix1!sugar!peter From: peter@sugar.UUCP (Peter da Silva) Newsgroups: comp.lang.c Subject: Problem with either ANSI 'C' or Dr Dobbs Journal. Message-ID: <449@sugar.UUCP> Date: Thu, 30-Jul-87 22:01:37 EDT Article-I.D.: sugar.449 Posted: Thu Jul 30 22:01:37 1987 Date-Received: Thu, 6-Aug-87 07:18:04 EDT Organization: Sugar Land UNIX - Houston, TX Lines: 30 According to an article on ANSI 'C' in Dr Dobb's Journal, a prototype with a fixed number of arguments means the routine may be called without unwinding the stack on return... the assumption being that the called routine popped its arguments with a "RET N" type instruction. It then adds that if no prototype is provided, the function may be assumed to have a fixed number of arguments. This is dangerous, in that it breaks existing code. Example: /* no #includes */ exec_system(s) char *s; { execl("/bin/sh", "sh", "-c", s, 0); printf("Shell not found.\n"); return 0; } Execl will be called as a routine that expects a fixed number of args. The stack will not be unwound. The routine will return to (probably) the address of the string "/bin/sh", leading to unusual results. On the other hand, if they don't make that assumption, any call you make without prototypes will lead to the stack being unwound twice. I don't know if there's an answer... perhaps this could be made an optional and defeatable extension? -- -- Peter da Silva `-_-' ...!seismo!soma!uhnix1!sugar!peter (I said, NO PHOTOS!)