mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
23 lines
761 B
D
23 lines
761 B
D
// See also: fail20000.d
|
|
/*
|
|
REQUIRED_ARGS: -de
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/cpp_cast.d(19): Error: cast from `cpp_cast.I` to `cpp_cast.C` is not allowed in a `@safe` function
|
|
fail_compilation/cpp_cast.d(19): No dynamic type information for extern(C++) classes
|
|
fail_compilation/cpp_cast.d(21): Deprecation: cast from `cpp_cast.C` to `cpp_cast.D` will become `@system` in a future release
|
|
fail_compilation/cpp_cast.d(21): No dynamic type information for extern(C++) classes
|
|
---
|
|
*/
|
|
extern(C++) interface I { void f(); }
|
|
extern(C++) class C : I { void f() { } }
|
|
extern(C++) class D : C { }
|
|
|
|
void main() @safe
|
|
{
|
|
I i;
|
|
C c = cast(C) i; // unsafe
|
|
i = cast(I) c; // OK
|
|
c = cast(D) c; // reinterpret cast
|
|
c = cast(C) new D; // OK
|
|
}
|