[Issue 23957] New: Casting to derived extern(C++) class is unsafe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 3 12:31:09 UTC 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 at puremagic.com
          Reporter: nick at 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.

--


More information about the Digitalmars-d-bugs mailing list