[Issue 814] lazy argument + variadic arguments = segfault
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jul 2 08:11:14 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=814
--- Comment #3 from Don <clugdbug at yahoo.com.au> 2009-07-02 08:11:13 PDT ---
In fact, by replacing the T arg line below with the commented out-line, it gets
the correct arguments. So in fact, it's just getting the size of the lazy
parameter wrong when it's calculating _argptr.
-------------
alias void* va_list;
template va_arg(T)
{
T va_arg(inout va_list _argptr)
{
T arg = *cast(T*)_argptr; // original from Phobos
// T arg = *(cast(T*)(cast(int *)_argptr+1));
_argptr = _argptr + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1));
return arg;
}
}
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!");
assert(tmp_msg=="food_for_thought");
}
int bar() { return 3; }
void main(){
foo(bar(),"food_for_thought");
}
--
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