www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - win64 vararg bug?

reply Benjamin Thaut <code benjamin-thaut.de> writes:
I have this small test program, it will crash when compiled on x64 
windows, but it works fine on 32bit windows. What am I doing wrong?

import core.vararg;
import std.stdio;

void print(string fmt, ...)
{
   auto arg = va_arg!(const(char)[])(_argptr);
   writefln(fmt ~ arg);
}

void main(string[] args)
{
   print("+++","---");
}

Kind Regards
Benjamin Thaut
-- 
Kind Regards
Benjamin Thaut
Feb 10 2013
next sibling parent Benjamin Thaut <code benjamin-thaut.de> writes:
Am 10.02.2013 09:18, schrieb Benjamin Thaut:
 import core.vararg;
 import std.stdio;

 void print(string fmt, ...)
 {
    auto arg = va_arg!(const(char)[])(_argptr);
    writefln(fmt ~ arg);
 }

 void main(string[] args)
 {
    print("+++","---");
 }

This only seems to happen when the argument before the variadic argument list is bigger then 8 byte. This works: void print(int fmt, ...) { auto arg = va_arg!(const(char)[])(_argptr); writefln("%s %s",fmt,arg); } void main(string[] args) { print(1,"---"); }
Feb 10 2013
prev sibling next sibling parent Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> writes:
On Sun, 10 Feb 2013 09:18:58 +0100
Benjamin Thaut <code benjamin-thaut.de> wrote:

 I have this small test program, it will crash when compiled on x64 
 windows, but it works fine on 32bit windows. What am I doing wrong?
 
 import core.vararg;
 import std.stdio;
 
 void print(string fmt, ...)
 {
    auto arg = va_arg!(const(char)[])(_argptr);
    writefln(fmt ~ arg);
 }
 
 void main(string[] args)
 {
    print("+++","---");
 }
 
 Kind Regards
 Benjamin Thaut

Might be related to these: http://d.puremagic.com/issues/show_bug.cgi?id=6576 http://d.puremagic.com/issues/show_bug.cgi?id=7893
Feb 10 2013
prev sibling next sibling parent "kinke" <noone hotmail.com> writes:
On Sunday, 10 February 2013 at 08:18:50 UTC, Benjamin Thaut wrote:
 I have this small test program, it will crash when compiled on 
 x64 windows, but it works fine on 32bit windows. What am I 
 doing wrong?

 import core.vararg;
 import std.stdio;

 void print(string fmt, ...)
 {
   auto arg = va_arg!(const(char)[])(_argptr);
   writefln(fmt ~ arg);
 }

 void main(string[] args)
 {
   print("+++","---");
 }

 Kind Regards
 Benjamin Thaut

This works for me when using https://github.com/ldc-developers/ldc/pull/287 and LLVM 3.2. LDC currently uses the incompatible System V ABI for Win64...
Feb 10 2013
prev sibling parent "kinke" <noone hotmail.com> writes:
Sorry about that, I thought I was browsing the LDC newsgroup. ;)
Feb 10 2013