-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Bugzilla 24434 - Casting away const with cast() is not a @safe lv… (
#16315) * Fix Bugzilla 24434 - Casting away const with cast() is not a @safe lvalue * Use `pointerTo` * Use cast to hide lvalue append error * Fix unsafe shared increment * Use setUnsafePreview * Add test for lvalue assign * Fix qualifier cast check * Workaround for safe append Fixes Bugzilla 23530 - casting immutable away allowed in safe. * Update header * Trigger tests
- Loading branch information
Showing
5 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
REQUIRED_ARGS: -preview=dip1000 -de | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/cast_qual.d(15): Deprecation: cast from `const(int)` to `int` cannot be used as an lvalue in @safe code | ||
fail_compilation/cast_qual.d(17): Deprecation: cast from `const(int)` to `int` cannot be used as an lvalue in @safe code | ||
--- | ||
*/ | ||
|
||
@safe: | ||
|
||
void main() { | ||
const int i = 3; | ||
int j = cast() i; // OK | ||
int* p = &cast() i; // this should not compile in @safe code | ||
*p = 4; // oops | ||
cast() i = 5; // NG | ||
auto q = &cast(const) j; // OK, int* to const int* | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters