#include <stdio.h>
#include <stdarg.h>
void foo( unsigned char a,
unsigned char b,
unsigned char c,
... )
{
va_list ap;
unsigned char d;
/*unsigned char *d = &a - 4;
printf( "c: %p\nb: %p\na: %p\n",
(void *)&c,
(void *)&b,
(void *)&a );
printf( "d: %hhu\n",
*d );*/
d
= va_arg ( ap
, unsigned char ) ; }
int main( void )
{
foo( 1 , 2 , 3 , 4 ) ;
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRhcmcuaD4KIAp2b2lkIGZvbyggdW5zaWduZWQgY2hhciBhLCAKCSAgdW5zaWduZWQgY2hhciBiLCAKCSAgdW5zaWduZWQgY2hhciBjLCAKCSAgLi4uICApCnsKCXZhX2xpc3QgYXA7Cgl1bnNpZ25lZCBjaGFyIGQ7CgkvKnVuc2lnbmVkIGNoYXIgKmQgPSAmYSAtIDQ7CgogICAgICAgIHByaW50ZiggImM6ICVwXG5iOiAlcFxuYTogJXBcbiIsIAogICAgICAgICAgICAgICAgKHZvaWQgKikmYywgCiAgICAgICAgICAgICAgICAodm9pZCAqKSZiLCAKICAgICAgICAgICAgICAgICh2b2lkICopJmEgKTsKICAgICAgICBwcmludGYoICJkOiAlaGh1XG4iLCAKCQkqZCApOyovCgoJdmFfc3RhcnQoIGFwLCBjICk7CglkID0gdmFfYXJnKCBhcCwgdW5zaWduZWQgY2hhcik7Cgl2YV9lbmQoIGFwICk7CglwcmludGYoICIlaGh1XG4iLCBkICk7Cn0KIAogCiAKaW50IG1haW4odm9pZCkKewogICAgICAgIGZvbyggMSwgMiwgMywgNCApOwogCiAKICAgICAgICByZXR1cm4gMDsKfQo=
compilation info
cc1: warnings being treated as errors
prog.c: In function ‘foo’:
prog.c:21: error: ‘unsigned char’ is promoted to ‘int’ when passed through ‘...’
prog.c:21: note: (so you should pass ‘int’ not ‘unsigned char’ to ‘va_arg’)
prog.c:21: note: if this code is reached, the program will abort
stdout