BUG? lazy argument + variadic arguments

Thomas Kuehne thomas-dloop at kuehne.cn
Sun Jan 7 10:48:07 PST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ville Mattila schrieb am 2007-01-07:
> 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.

The "lazy void expression" causes the problem. I'm unsure if
"lazy void" is legal, but it certanly causes an incorrect code
generation.

Please file this bug at:
http://d.puremagic.com/issues/

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFFoUyoLK5blCcjpWoRAjCHAKCHEQ/DlwwGGTC5VvToJWcRHA63NwCfb83c
HZRgyGkWxkZNxs2R6d/YbTA=
=miy4
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-learn mailing list