segmentation fault with Object.factory()
berni via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Feb 19 03:13:16 PST 2017
On Sunday, 19 February 2017 at 10:15:49 UTC, rikki cattermole
wrote:
>> What's wrong here?
>
> void main()
> {
> A bar = cast(A)Object.factory(__MODULE__ ~ ".AA");
> bar.foo();
> }
Oops. I overdid when trying to create a small example. With the
module it works, but my original program had the module and still
produced an segmentation fault. After some more investigations I
found out, that it was not due to a mistake in the program, but
because rdmd didn't recompile after I called it with an
--extra-file added. Looks like a bug in rdmd... Here is a small
example:
test.d:
>module test;
>
>import std.stdio;
>
>void main()
>{
> B tmp = cast(B)Object.factory("test2.BB");
> tmp.m1();
>}
>
>interface A { abstract void m1(); }
>interface B:A { abstract void m2(); }
>class AA:A { override void m1() { writeln("A"); } }
test2.d:
>module test2;
>
>import std.stdio;
>import test;
>
>class BB:AA,B { override void m2() { writeln("B"); } }
And here is what I get when compiling:
>$> rdmd test.d
>segmentation fault
>$> rdmd --extra-file=test2.d test.d
>segmentation fault
>$> rm -rf /tmp/.rdmd-1000/
>$> rdmd --extra-file=test2.d test.d
>A
>$> rdmd -version
>rdmd build 20170122
>[...]
Should I report this bug anywhere (or am I wrong again?)
More information about the Digitalmars-d-learn
mailing list