Merge pull request #2226 from hpohl/10359

fix issue 10359 - Pointer slicing allowed in @safe mode
This commit is contained in:
Don Clugston 2013-06-19 09:58:54 -07:00
commit a80a4cc99e
2 changed files with 13 additions and 0 deletions

View file

@ -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)
{ {

View 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];
}