[Issue 20000] New: Casting to interfaces arbitrarily disallowed in @safe code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 23 21:23:42 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20000

          Issue ID: 20000
           Summary: Casting to interfaces arbitrarily disallowed in @safe
                    code
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: n8sh.secondary at hotmail.com

```
interface A {}
class C1 {}
class C2 : A {}

bool isA(Object obj) @safe
{
    if (auto a = cast(A) obj)
        return true;
    return false;
}

void main()
{
    import std.stdio : writeln;
    writeln(isA(new C1()));
    writeln(isA(new C2()));
}
```

--


More information about the Digitalmars-d-bugs mailing list