www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1401] New: Multiple inheritance of abstract template classes lead to segmentation fault.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1401

           Summary: Multiple inheritance of abstract template classes lead
                    to segmentation fault.
           Product: D
           Version: 2.003
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: frank-fischer shadow-soft.de


The following code using an abstract template class and multiple inheritance
produces a segmentation fault.

---
module mytest;

import std.stdio;

interface A(T) {
    C!(T) func();
    size_t f();
}

abstract class B(T): A!(T) {
}

interface C(T): A!(T) {
}

class D: B!(int), C!(int) {
    size_t f() { return 42; }
    C!(int) func() { return this; }
}

void main() {
    A!(int) x = new D();
    writefln("%d", x.f());
}
---

When I compile this snippet with dmd 2.003 on my linux-box, I get a
segmentation fault on the call "x.f()" in the last line. Furthermore, if I
use an interface instead of an abstract class for B, everything is fine.
Even if I just change the order of definition of 'func' and 'f' in A, i.e.

interface A(T) {
    size_t f();
    C!(T) func();
}

everything works.


-- 
Aug 04 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1401


gide nwawudu.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME





Works in D2.026.


-- 
Apr 23 2009