Skip to content

core.stdc.stdarg doesn't work on 64 bits #73

@SiegeLord

Description

@SiegeLord
import stdarg = core.stdc.stdarg;
import vararg = core.vararg;
import std.stdio;

version(DigitalMars) version(X86_64)
    import core.stdc.stdarg : __va_argsave_t;

// Use core.vararg
void test1(...)
{
    foreach(type; _arguments)
    {
        writeln(vararg.va_arg!(int)(_argptr));
    }
}

// Use core.stdc.stdarg #1
void test2(...)
{
    foreach(type; _arguments)
    {
        writeln(stdarg.va_arg!(int)(cast(stdarg.va_list)_argptr));
    }
}

// Use core.stdc.stdarg #2
void test3(...)
{
    foreach(type; _arguments)
    {
        void[] buffer = new void[type.tsize];
        stdarg.va_arg(cast(stdarg.va_list)_argptr, type, buffer.ptr);
        writeln(*(cast(int*)buffer.ptr));
    }
}

void main()
{
    test1(42); //Works ok
    test2(42); //Prints out junk
    test3(42); //SIGSEGV
}

The va_arg functions in core.stdc.stdarg don't seem to work. They require a cast (see code) to even compile properly, and after that they don't work. All 3 functions compile and function fine on DMD 2.057 32 and 64 bits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions