From Bugzilla Helper: User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.2-2 i686) [mm7323@mike bug]$ cat bug.c #include <stdarg.h> #include <stdio.h> typedef unsigned short myType; void func(int n,...) { va_list ap; myType b; va_start(ap,n); b=va_arg(ap,myType); va_end(ap); printf("%d\n",b); } int main(int argC,char *argV[]) { func(1,12345); return 0; } [mm7323@mike bug]$ gcc bug.c bug.c: In function `func': bug.c:11: `myType' is promoted to `int' when passed through `...' bug.c:11: (so you should pass `int' not `myType' to `va_arg') [mm7323@mike bug]$ Reproducible: Always Steps to Reproduce: 1. Attempt to compile the test program given in the description 2. 3. Actual Results: bug.c: In function `func': bug.c:11: `myType' is promoted to `int' when passed through `...' bug.c:11: (so you should pass `int' not `myType' to `va_arg') Expected Results: It should just compile making a.out. I understood that anything can be passed to va_arg, not just ints. This prevents some software from being compiled e.g. lib icq...
C promotes char and short to int when passing to ... arguments. The compiler is right to make it obvious this is a bug. A varargs function will simply never get a char or short as vararg, therefore if you want to pass a short through varargs, you should use (myType)va_arg(ap, int). Similarly with float (which is promoted to double). If there are programs which don't do this, they should be fixed.