| 1 |
// See also: fail20000.d |
| 2 |
/* |
| 3 |
REQUIRED_ARGS: -de |
| 4 |
TEST_OUTPUT: |
| 5 |
--- |
| 6 |
fail_compilation/cpp_cast.d(19): Error: cast from `cpp_cast.I` to `cpp_cast.C` is not allowed in a `@safe` function |
| 7 |
fail_compilation/cpp_cast.d(19): No dynamic type information for extern(C++) classes |
| 8 |
fail_compilation/cpp_cast.d(21): Deprecation: cast from `cpp_cast.C` to `cpp_cast.D` will become `@system` in a future release |
| 9 |
fail_compilation/cpp_cast.d(21): No dynamic type information for extern(C++) classes |
| 10 |
--- |
| 11 |
*/ |
| 12 |
extern(C++) interface I { void f(); } |
| 13 |
extern(C++) class C : I { void f() { } } |
| 14 |
extern(C++) class D : C { } |
| 15 |
|
| 16 |
void main() @safe |
| 17 |
{ |
| 18 |
I i; |
| 19 |
C c = cast(C) i; // unsafe |
| 20 |
i = cast(I) c; // OK |
| 21 |
c = cast(D) c; // reinterpret cast |
| 22 |
c = cast(C) new D; // OK |
| 23 |
} |