va_arg seems to mess up the va_list when variadic variables have size 0, but when have large alignment requirements. When the alignment is small, this seems to work by chance.
$ gcc foo.c -o foo && ./foo 3 0 #include <stdarg.h> #include <stdio.h> typedef int __attribute__ ((vector_size (16))) foo_t; struct s { foo_t f[0]; } s1; void check (int x, ...) { int y; va_list ap; va_start (ap, x); va_arg (ap, struct s); y = va_arg (ap, int); /* Expect output: 3 7 */ printf ("%d %d\n", x, y); } int main() { check (3, s1, 7); return 0; } -- Summary: va_arg gets confused when skipping over certain zero- sized types Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: wrong-code Severity: major Priority: P2 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bje at gcc dot gnu dot org GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24306