-
-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 15703 - @safe code should not allow certain types of array …
…casts
- Loading branch information
1 parent
627e96b
commit 811ddf9
Showing
2 changed files
with
40 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
REQUIRED_ARGS: -m32 | ||
PERMUTE_ARGS: | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/test15703.d(17): Error: cast from Object[] to uint[] not allowed in safe code | ||
fail_compilation/test15703.d(19): Error: cast from object.Object to const(uint)* not allowed in safe code | ||
fail_compilation/test15703.d(22): Error: cast from uint[] to Object[] not allowed in safe code | ||
--- | ||
*/ | ||
|
||
// https://issues.dlang.org/show_bug.cgi?id=15703 | ||
|
||
void test() @safe | ||
{ | ||
auto objs = [ new Object() ]; | ||
auto longs = cast(size_t[]) objs; // error | ||
auto longc = cast(const(size_t)[]) objs; // ok | ||
auto longp = cast(const(size_t)*) objs[0]; // error | ||
|
||
size_t[] al; | ||
objs = cast(Object[]) al; // error | ||
} |