tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] va_list bug on x86_64, version 0.9.27


From: DFP
Subject: [Tinycc-devel] va_list bug on x86_64, version 0.9.27
Date: Thu, 13 Feb 2025 12:36:24 +0100

Hello.

va_arg seems to take the value from unexpected location on x86_64, in a case 
where a variable argument function returns a struct that is larger than 16 
bytes. I tested on plain x86 (32 bit) via JSLinux 
(https://bellard.org/jslinux/vm.html?url=alpine-x86-xwin.cfg&mem=256&graphic=1) 
and the issue does not seem to occur there. Can anyone reproduce? Code listed 
below, which erroneously prints '3' instead of '17':

#include <stdarg.h>
#include <stdio.h>

struct s {
        char a[17];
} s;

struct s f( int a, ... )
{
        va_list args;
        va_start( args, a );

        printf( "%d\n", va_arg( args, int ) );

        va_end(args);
        return (struct s){0};
}

int main()
{
        f( 3, 17 );
        return 0;
}



reply via email to

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