std.signals regressions
Denis Shelomovskij
verylonglogin.reg at gmail.com
Fri Jun 14 22:58:16 PDT 2013
14.06.2013 18:31, David пишет:
> This code currently fails with a RangeError (used to work in 2.062)
>
> // http://dpaste.dzfl.pl/332a71ec
> import std.stdio;
> import std.signals;
>
>
> struct X {
> mixin Signal!();
> }
>
> class O {
> void m() {}
> }
>
> void main() {
> O o = new O();
> X[string] aa;
> aa["o"] = X.init;
> aa["o"].connect(&o.m);
>
>
> /*{ // 20
> X x = aa["o"];
> }*/
> }
>
>
> If you take the uncomment the "block" at line 20 you end up with a
> segmentation fault, also worked in 2.062. Both times the problem is in
> the __dtor (segfault happens in the call to "_d_toObject(stor.ptr)".
>
> Changing "struct" to "class" and "X.init" to "new X()" it seems to work
> as it should.
> Is this worth a bugreport or was the old behaviour never intended?
> This bug (I consider it one) broke quite a few lines of code... If the
> old behaviour was never intended, why wasn't it documentated then... oh
> well I am drifting into another D rant here...
>
http://dlang.org/phobos/std_signals.html#Signal
"Mixin to create a signal within a class object."
So your `X` must be a class.
Also don't use std.signals - it's an incorrect and dangerous mess (see
bug tracker).
--
Денис В. Шеломовский
Denis V. Shelomovskij
More information about the Digitalmars-d
mailing list