Menu

#39 GDC dynamic cast works improperly

v1.0 (example)
closed-fixed
nobody
5
2008-04-19
2008-02-13
No

During my testing of Tango, I discovered the following nasty bug in GDC, interfaces are not downcast properly. Attached is a simple testcase.

It appears that the interfaces part of the ClassInfo is not filled properly when using interfaces.

Discussion

  • Anonymous

    Anonymous - 2008-02-13

    Testrun Interfaces Feb 13th, 2008

     
  • Valeriu Palos

    Valeriu Palos - 2008-04-08

    Logged In: YES
    user_id=1286246
    Originator: NO

    I can confirm this! The example below triggers the above-mentioned bug. After some debugging it boiled down to an obscure error somwhere in the _d_isbaseof2() function in phobos/internal/cast.d.

    module castbug;

    interface I1 {
    void f1();
    }

    interface I2 :I1 {
    void f2();
    }

    class C1 : I1 {
    void f1() {};
    }

    class C2 : I2 {
    void f1() {};
    void f2() {};
    }

    int main(char[][] args)
    {
    auto c1 = new C1();
    auto c2 = new C2();

    auto t = cast(C1)c2; /* SEGFAULT on x86_64 */

    return 0;
    }

    I think this is a pretty serious bug!

     
  • David Friedman

    David Friedman - 2008-04-19

    Logged In: YES
    user_id=1378044
    Originator: NO

    Fixed in release 0.25 / svn 212.

    This was a bug in GDC and not _d_isbaseof2. There is, however, another interface cast problem in the DMD front end and/or _d_isbaseof2: http://d.puremagic.com/issues/show_bug.cgi?id=2013

     
  • David Friedman

    David Friedman - 2008-04-19
    • status: open --> closed-fixed
     

Log in to post a comment.