[phobos] phobos commit, revision 1553
Shin Fujishiro
rsinfu at gmail.com
Mon May 24 23:29:15 PDT 2010
> Then std.functional segfaults :o/.
Reproduced! unittests for toDelegate() segfault with -O.
obj2asm showed that everything in toDelegate() was optimized away if
compiled with the -O option. Then an uninitialized delegate object was
returned.
Workaround:
--------------------
--- phobos/std/functional.d
+++ phobos/std/functional.d
@@ -590,7 +590,8 @@ auto ref toDelegate(F)(auto ref F fp) if
(isCallable!(F)) { auto dummyDel = &(dummy.doIt);
df.funcPtr = dummyDel.funcptr;
- return df.del;
+ auto del = df.del;
+ return del;
}
}
--------------------
toDelegate() is an auto ref function. A compiler bug allows the local
variable df.del to be returned by reference. I'm not very sure, but it
leads toDelegate() to return (reference to) uninitialized value.
I filed the bug into bugzilla:
http://d.puremagic.com/issues/show_bug.cgi?id=4232
Shin
More information about the phobos
mailing list