Hello!
This is my first email to a mailing list so apologies if anything
looks strange.
It seems I have discovered a bug in TCCs compilation of varargs.
I'm on "tcc version 0.9.27 (x86_64 Linux)".
Please see the following code:
- - - - -
#include <stdio.h>
#include <stdarg.h>
struct test {
void *foo, *bar, *baz;
};
struct test example(int a, int b, ...)
{
va_list va;
va_start(va, b);
printf("a: %d, b: %d, va_arg: %d\n", a, b, va_arg(va, int));
va_end(va);
return (struct test) {};
}
int main()
{
example(1, 2, 3);
return 0;
}
- - - - -
$ tcc -run example.c
a: 1, b: 2, va_arg: 2
- - - - -
GCC and Clang both give "va_arg: 3" which is what I'd expect from
this code.
It seems to happen when returning a non-trivial struct from the
function which has varargs.
Thanks for reading,
Marcus