This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

can't pass char through va_list


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]