www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3360] New: segfault with alias this and inner classes

http://d.puremagic.com/issues/show_bug.cgi?id=3360

           Summary: segfault with alias this and inner classes
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrei metalanguage.com


--- Comment #0 from Andrei Alexandrescu <andrei metalanguage.com> 2009-10-02
10:55:47 PDT ---
This correct example causes a segfault:

import std.stdio;

class Base1 {
    void fun() { writeln("Base.fun"); }
}

class Base2 {
    void gun() { writeln("Base.fun"); }
}

class Multiple : Base1 {
    // Override method in Base1
    override void fun() { writeln("Multiple.fun"); }
    // Override method in Base2
    class MyBase2 : Base2 {
        override void gun() { writeln("Multiple.gun"); }
    }
    // Effect multiple inheritance
    Base2 _base2;
    alias _base2 this;
    this() {
        _base2 = new MyBase2;
    }
}

void main()
{
    auto obj = new Multiple;
    Base1 obj1 = obj;
    obj1.fun();
    Base2 obj2 = obj;
    obj2.gun();    
}

Replacing obj2.gun() with obj.gun() makes the code work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2009