[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] x86_64: second struct va_arg fails
From: |
Henry Kroll |
Subject: |
[Tinycc-devel] x86_64: second struct va_arg fails |
Date: |
Mon, 13 Dec 2010 00:24:31 -0800 |
x86_64 fails to copy the second struct passed to va_arg.
Notice that if you switch the position of bill= and george= it is always
the second struct that fails to read.
$ gcc test.c && ./a.out #pass
$ i386-tcc test.c && ./a.out #pass
$ tcc test.c && ./a.out #fail
failed in test.c: 20
test.c--------------------------
#include <stdio.h>
#include <stdarg.h>
#define failed() do { \
printf("failed in %s: %d\n", __FILE__, __LINE__); \
errors++; \
} while (0)
static int errors = 0;
static struct myspace {
short int profile;
} bob = { 42 };
void badfunc(int eek, ...) {
va_list ack;
int validate;
struct myspace george, bill;
va_start(ack, eek);
bill = va_arg(ack, struct myspace);
george = va_arg(ack, struct myspace);
validate = va_arg(ack, int);
if (bill.profile != bob.profile) failed();
if (george.profile != bob.profile) failed();
if (validate != bob.profile) failed();
va_end(ack);
}
void goodfunc(int eek, struct myspace george) {
if (george.profile != bob.profile) failed();
}
int main(int argc, char **argv) {
goodfunc(0, bob);
badfunc(0, bob, bob, bob.profile);
return errors;
}
- [Tinycc-devel] x86_64: second struct va_arg fails,
Henry Kroll <=