dmd/compiler/test/fail_compilation/system_ptr_cast.d
Dennis 9b94878c85
Make safe error messages consistent (#20654)
Co-authored-by: Dennis Korpel <dennis@sarc.nl>
2025-01-08 13:46:38 +08:00

25 lines
668 B
D

/*
REQUIRED_ARGS: -preview=dip1000 -de
TEST_OUTPUT:
---
fail_compilation/system_ptr_cast.d(20): Deprecation: cast from `S*` to `int*` will become `@system` in a future release
fail_compilation/system_ptr_cast.d(20): Source element type has unsafe bit patterns and target element type is mutable
fail_compilation/system_ptr_cast.d(24): Deprecation: cast from `int*` to `S*` will become `@system` in a future release
fail_compilation/system_ptr_cast.d(24): Target element type has unsafe bit patterns
---
*/
struct S
{
@system int i;
}
void main() @safe
{
S s;
auto p = cast(int*) &s;
*p = 8;
int i = 8;
auto ps = cast(S*) &i;
}