The following works on i386, sparc32 and sparc64, but produces a compiler warning on x86-64, then prints garbage and crashses when run:
--------------------------- #include <stdarg.h> #include <stdio.h> void func3(va_list *ap) { int test = va_arg(*ap,int); fprintf(stderr,"%d\n",test); } void func2(va_list ap) { func3(&ap); } void func1(int start, ...) { va_list ap; va_start(ap,start); func2(ap); va_end(ap); } int main() { fprintf(stderr,"This should print 1:\n"); func1(2,1); return 0; } --------------------------- test.c: In function `func2': test.c:10: warning: passing arg 1 of `func3' from incompatible pointer type --------------------------- This should print 1: -7609280 Segmentation fault -- Summary: va_list passing breaks on x86-64 only Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ian-gccbug at penguinhosting dot net GCC build triplet: x86_64-pc-linux-gnu GCC host triplet: x86_64-pc-linux-gnu GCC target triplet: x86_64-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26294