Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!spool.mu.edu!olivea!oliveb!veritas!tsai From: tsai@Veritas.COM (Cary Tsai) Newsgroups: comp.lang.c Subject: Need help in Message-ID: <1991Jun12.174326.5390@Veritas.COM> Date: 12 Jun 91 17:43:26 GMT Organization: VERITAS Software Lines: 56 Could you C guru tell me why the third ooprint() stmt causes coredump. I must be missing something in ooprint(). Compile and execute 'a.out'. You'll get 'flag is on', 'flag is off' and ...(coredump) or any bus error message. /* help .... */ #include #include typedef void (*PFV)(); void ooprint(va_alist) va_dcl { va_list ap; PFV func; char *client; char *foo; va_start(ap); foo = va_arg(ap, char *); if ((func = va_arg(ap, PFV)) != (PFV) 0) { if ((client = va_arg(ap, char *)) != (char *) 0) func(client); } va_end(ap); } void testFunc1(testData) char *testData; { if (testData && *testData) puts(testData); } void testFunc2(testData) char *testData; { if (testData && *testData) puts(testData); } main() { static char *mess1 = "flag is on"; static char *mess2 = "flag is off"; ooprint("ooprint", testFunc1, mess1); ooprint("ooprint", testFunc2, mess2); ooprint("ooprint"); /* WHY THIS STMT CAUSES CORE-DUMP? */ } /* end of help ... */ You help and information would be appreciated.