[Issue 814] lazy argument + variadic arguments = segfault

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 2 07:58:20 PDT 2009


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


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au
            Summary|lazy argument + variadic    |lazy argument + variadic
                   |arguments                   |arguments = segfault




--- Comment #2 from Don <clugdbug at yahoo.com.au>  2009-07-02 07:58:19 PDT ---
Reduced test case shows it's an out-by-1 error in grabbing the arguments. The
length ends up in the ptr field.
Probably, it's neglecting the fact that lazy arguments have a pointer as well
as the value, or something similar.

import std.stdarg;

void foo(lazy int expr, ...){
    char[] tmp_msg = va_arg!(char[])(_argptr);
    if (cast(int)(tmp_msg.ptr)=="food_for_thought".length)
         assert(0, "length is in the pointer!");
}

void main(){
  foo(515,"food_for_thought");
}

Applies to D2 as well as D1.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list