Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!decvax!decwrl!ucbvax!MIMSY.UMD.EDU!chris From: chris@MIMSY.UMD.EDU.UUCP Newsgroups: mod.computers.pyramid Subject: Re: another c bug? Message-ID: <8608012332.AA29573@mimsy.umd.edu> Date: Fri, 1-Aug-86 19:32:01 EDT Article-I.D.: mimsy.8608012332.AA29573 Posted: Fri Aug 1 19:32:01 1986 Date-Received: Sat, 2-Aug-86 03:57:17 EDT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 68 Approved: info-pyramid@mimsy.umd.edu This is not a compiler bug. It is not legal to take the address of one argument and use that to compute the address of another argument. It works on all pure stack machines as long as you know the direction of stack growth. It does not work on mixed stack/register machines like the Pyramid. The proper thing to do in larn's case is to use varargs and vprintf. I am not sure if vprintf is in the `ucb universe' C library, but vprintf(fmt, args) char *fmt; va_list args; { _doprnt(fmt, args, stdout); } should work (since I know how Pyramid did their varargs). Given vprintf, change show_int_args (args) int args; { int *pargs; int i; pargs = &args; while (*pargs != 0) printf ("%d : ", *pargs++); printf ("%d\n", 0); } to #include show_int_args(va_alist) va_dcl { register int i; va_list p; va_start(p); for (;;) { i = va_arg(p, int); if (i == 0) break; printf("%d : ", i); } printf("0\n"); /* simplified */ va_end(p); } /* emulate a standard printf() */ xprintf(va_alist) va_dcl { char *fmt; va_list p; va_start(p); fmt = va_arg(p, char *); vprintf(fmt, p); va_end(p); } Chris