tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] vararg compilation bug


From: Marcus Ramse
Subject: Re: [Tinycc-devel] vararg compilation bug
Date: Tue, 13 Apr 2021 11:38:13 +0200

Thank you!

On 2021-04-13 11:34, Herman ten Brugge wrote:
This should be fixed now.

    Herman

On 4/11/21 5:50 AM, Marcus Ramse wrote:
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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]