From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,81a5ff734b7d4059,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1993-07-14 09:47:20 PST Newsgroups: comp.unix.osf.osf1 Path: gmd.de!newsserver.jvnc.net!howland.reston.ans.net!torn!watserv2.uwaterloo.ca!watmath!rbutterw From: rbutterw@math.uwaterloo.ca (Ray Butterworth [MFCF]) Subject: Problems with Message-ID: Sender: news@math.uwaterloo.ca (News Owner) Organization: Math Faculty Computing Facility, University of Waterloo Date: Wed, 14 Jul 1993 15:57:16 GMT seems to get the initial offset of the variable argument list wrong in some cases. I have a fix that seems to work for the problems that I ran into. Script started on Wed Jul 14 10:20:37 1993 osf1# cc v.c osf1# ./a.out 1 2 3.1 3.2 3.2 four osf1# cc -DFIXIT v.c osf1# ./a.out 1 2 3.1 3.2 four five osf1# cat v.c #include #include #if !defined(FIXIT) /* #define va_start(list, parmN) __builtin_va_start(list, parmN, 1) */ #else # undef va_start # define va_start(list, parmN) \ (__builtin_va_start(list, parmN, 1), \ (list).offset = ((char*)&parmN - (list).a0) \ + ((sizeof(parmN) + 7) & ~7)) #endif static struct blivit { char *x1; char *x2; } thing = { "3.1", "3.2" }; static void test(int n1, int n2, struct blivit stuff, ...) { auto va_list args; auto char *a4; auto char *a5; va_start(args, stuff); a4 = va_arg(args, char*); a5 = va_arg(args, char*); printf("%d %d %s %s %s %s\n", n1, n2, stuff.x1, stuff.x2, a4, a5); va_end(args); } main(int argc, char **argv) { test(1, 2, thing, "four", "five"); } osf1# exit script done on Wed Jul 14 10:21:12 1993