[Issue 814] New: lazy argument + variadic arguments

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 7 11:50:28 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=814

           Summary: lazy argument + variadic arguments
           Product: D
           Version: 1.00
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: ville.mattila at iki.fi


Hello,

 I'm very new to d. I'm testing lazy evaluation and it seems like
 I've found bug w/ dmd  compiler on linux. Here are the details.


-- foo.d ---

import std.stdio;
import std.stdarg;
import std.string, std.conv, std.stream;
void foo(lazy void expression, ...)
{
  //expression();
  if (_arguments.length > 0) {
    _arguments[0].print();
    //writefln("got vararg:" ~ _arguments[0].name);
    if ((_arguments[0]) == typeid(char[])) {
      writefln("got vararg:" ~ std.conv.toString(_arguments.length));
      char[] tmp_msg = va_arg!(char[])(_argptr);
      writefln("GOOTT vararg: " ~ tmp_msg);

    }
  }
}

int main(char[][] args)
{
  foo(writefln("barz"),"foo");
  return(0);
}

--- foo.d ----

./foo
char[]
got vararg:1
Segmentation fault (core dumped)
mulperi at mulperi-desktop:/usr/local/src/apps/d/dmd/samples/d$ dmd --help
Digital Mars D Compiler v1.0
Copyright (c) 1999-2007 by Digital Mars written by Walter Bright
Documentation: www.digitalmars.com/d/index.html
Usage:
  dmd files.d ... { -switch }

I'm usring xubuntu 6.10 w/ latest patches.

 - Ville


-- 



More information about the Digitalmars-d-bugs mailing list