June 03, 2023
https://issues.dlang.org/show_bug.cgi?id=23957

          Issue ID: 23957
           Summary: Casting to derived extern(C++) class is unsafe
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: nick@geany.org

extern(C++) class C { void f() { } }
extern(C++) class D : C { }

void main() @safe
{
    assert(cast(D)(new C) is null); // would fail as RTTI not checked
    auto c = cast(C)(new D); // OK
}

PR incoming.

--