segmentation fault with Object.factory()

rikki cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 19 02:15:49 PST 2017


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();
}


More information about the Digitalmars-d-learn mailing list