fork download
  1. #include <stdio.h>
  2. #include <stdarg.h>
  3.  
  4. void foo( unsigned char a,
  5. unsigned char b,
  6. unsigned char c,
  7. ... )
  8. {
  9. va_list ap;
  10. unsigned char d;
  11. /*unsigned char *d = &a - 4;
  12.  
  13.   printf( "c: %p\nb: %p\na: %p\n",
  14.   (void *)&c,
  15.   (void *)&b,
  16.   (void *)&a );
  17.   printf( "d: %hhu\n",
  18. *d );*/
  19.  
  20. va_start( ap, c );
  21. d = va_arg( ap, unsigned char);
  22. va_end( ap );
  23. printf( "%hhu\n", d );
  24. }
  25.  
  26.  
  27.  
  28. int main(void)
  29. {
  30. foo( 1, 2, 3, 4 );
  31.  
  32.  
  33. return 0;
  34. }
  35.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
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
Standard output is empty