[Issue 9500] New: Interfaces - shared static this

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 12 14:54:03 PST 2013


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

           Summary: Interfaces - shared static this
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: admin at dav1d.de


--- Comment #0 from David <admin at dav1d.de> 2013-02-12 14:54:00 PST ---
This segfaults:

---------
interface IFace {
    void log();
}

class Multi : IFace {
    IFace[] faces;

    this(IFace[] faces...) {
        this.faces = faces;
    }

    override void log() {
        foreach(face; faces) {
            if(face !is null) {
                face.log();
            }
        }
    }
}

class Bla : IFace {
    override void log() {}
}

/+__gshared+/ Multi m;

shared static this() {
    m = new Multi(new Bla());
}

void main() {
    m.log();
}
---------

Fixed if:
* shared static this -> static this
* or shared static this is changed to:

shared static this() {
    IFace i = new Bla();
    m = new Multi([i]);
}

(passing an array explicitly)

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


More information about the Digitalmars-d-bugs mailing list