This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
can't pass char through va_list
- To: gcc-bugs at gcc dot gnu dot org
- Subject: can't pass char through va_list
- From: Jon Wilkening <wilkenin at math dot lbl dot gov>
- Date: Thu, 4 May 2000 12:15:04 -0700 (PDT)
Hello,
The following code doesn't work right with gcc-2.95.2
running on a sun ultra-1 under solaris 2.7:
#include <stdio.h>
#include <stdarg.h>
void test(int d, ...) {
va_list ap;
char buf[4]={'a','b','c','\0'};
va_start(ap, d);
buf[2] = va_arg(ap, char);
printf("%s\n", buf);
va_end(ap);
}
main() {
test(1, '7');
}
The result should be
ab7
but instead I get
ab
It works correctly on an intel pentium III running red hat linux 6.0,
or if you change char to int in va_arg(ap,char). (I didn't compile
with any flags. just gcc va_arg.c)
Thank you,
Jon Wilkening