mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
Merge pull request #2226 from hpohl/10359
fix issue 10359 - Pointer slicing allowed in @safe mode
This commit is contained in:
commit
a80a4cc99e
2 changed files with 13 additions and 0 deletions
|
@ -9848,6 +9848,8 @@ Lagain:
|
||||||
{ error("need upper and lower bound to slice pointer");
|
{ error("need upper and lower bound to slice pointer");
|
||||||
return new ErrorExp();
|
return new ErrorExp();
|
||||||
}
|
}
|
||||||
|
if (sc->func && !sc->intypeof && sc->func->setUnsafe())
|
||||||
|
error("pointer slicing not allowed in safe functions");
|
||||||
}
|
}
|
||||||
else if (t->ty == Tarray)
|
else if (t->ty == Tarray)
|
||||||
{
|
{
|
||||||
|
|
11
test/fail_compilation/diag10359.d
Normal file
11
test/fail_compilation/diag10359.d
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
/*
|
||||||
|
TEST_OUTPUT:
|
||||||
|
---
|
||||||
|
fail_compilation/diag10359.d(10): Error: pointer slicing not allowed in safe functions
|
||||||
|
---
|
||||||
|
*/
|
||||||
|
|
||||||
|
void foo(int* p) @safe
|
||||||
|
{
|
||||||
|
auto a = p[0 .. 10];
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue