[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] vararg compilation bug
From: |
Christian Jullien |
Subject: |
Re: [Tinycc-devel] vararg compilation bug |
Date: |
Sun, 11 Apr 2021 15:26:13 +0200 |
Hi,
I confirm that this issue also exists with mob (which now displays git short
hash):
[jullien@fedora64 ~]$ tcc -v
tcc version 0.9.27 - 035ae7d (x86_64 Linux)
-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org] On
Behalf Of Marcus Ramse
Sent: Sunday, April 11, 2021 05:51
To: tinycc-devel@nongnu.org
Subject: [Tinycc-devel] vararg compilation bug
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
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel