Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 19, 2017 segmentation fault with Object.factory() | ||||
---|---|---|---|---|
| ||||
I get a segmentation fault, when I run this program:
>void main()
>{
> A bar = cast(A)Object.factory("AA");
> bar.foo();
>}
>
>class A { abstract void foo(); }
>class AA:A { override void foo() {} }
The call of bar.foo() is, where the segmentation fault occurs. When I use A bar = new AA(); instead of the factory it works.
What's wrong here?
|
February 19, 2017 Re: segmentation fault with Object.factory() | ||||
---|---|---|---|---|
| ||||
Posted in reply to berni | On 19/02/2017 11:06 PM, berni wrote: > I get a segmentation fault, when I run this program: > >> void main() >> { >> A bar = cast(A)Object.factory("AA"); >> bar.foo(); >> } >> >> class A { abstract void foo(); } >> class AA:A { override void foo() {} } > > The call of bar.foo() is, where the segmentation fault occurs. When I > use A bar = new AA(); instead of the factory it works. > > What's wrong here? void main() { A bar = cast(A)Object.factory(__MODULE__ ~ ".AA"); bar.foo(); } |
February 19, 2017 Re: segmentation fault with Object.factory() | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | 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?) |
February 19, 2017 Re: segmentation fault with Object.factory() | ||||
---|---|---|---|---|
| ||||
Posted in reply to berni | On 02/19/2017 12:13 PM, berni wrote: > 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?) Looks like a bug, yes. Please report on <https://issues.dlang.org/>. For "component" choose "tools". |
Copyright © 1999-2021 by the D Language Foundation