@@ -3771,34 +3771,39 @@ $(H3 $(LNAME2 safe-functions, Safe Functions))
37713771
37723772 $(P Safe functions have $(RELATIVE_LINK2 safe-interfaces, safe
37733773 interfaces). An implementation must enforce this by restricting the
3774- function's body to operations that are known safe.)
3774+ function's body to operations that are known to be safe,
3775+ except for calls to $(RELATIVE_LINK2 trusted-functions, `@trusted` functions).)
37753776
3776- $(P The following operations are not allowed in safe
3777+ $(P The following restrictions are enforced by the compiler in safe
37773778 functions:)
37783779
37793780 $(UL
3780- $(LI No casting from a pointer type to any type with pointers other than $(CODE void*).)
3781+ $(LI No casting from a pointer type `T` to any type `U` with pointers, except when:)
3782+ * `T` implicitly converts to `U`
3783+ * `U` implements class or interface `T`
3784+ * Both types are dynamic arrays
3785+ * `T.opCast!U` is `@safe`
37813786 $(LI No casting from any non-pointer type to a pointer type.)
37823787 $(LI No pointer arithmetic (including pointer indexing).)
3783- $(LI Cannot access unions that have pointers or references overlapping
3784- with other types.)
3785- $(LI Cannot access unions that have fields with invariants overlapping
3786- with other types.)
3788+ $(LI Cannot access unions that:)
3789+ * Have pointers or references overlapping with other types
3790+ * Have fields with invariants overlapping with other types
37873791 $(LI Calling any $(RELATIVE_LINK2 system-functions, System Functions).)
37883792 $(LI No catching of exceptions that are not derived from
37893793 $(LINK2 https://dlang.org/phobos/object.html#.Exception, $(D class Exception)).)
37903794 $(LI No inline assembler.)
3791- $(LI No explicit casting of mutable objects to immutable.)
3792- $(LI No explicit casting of immutable objects to mutable.)
3793- $(LI No explicit casting of thread local objects to shared.)
3794- $(LI No explicit casting of shared objects to thread local.)
3795- $(LI Cannot access $(D __gshared) variables.)
3796- $(LI Cannot use $(D void) initializers for pointers.)
3797- $(LI Cannot use $(D void) initializers for class or interface references.)
3798- $(LI Cannot use $(D void) initializers for types that have invariants.)
3799- )
3800-
3801- $(P When indexing or slicing an array, an out of bounds access
3795+ $(LI No explicit casting of:)
3796+ * mutable objects to immutable
3797+ * immutable objects to mutable
3798+ * thread local objects to shared
3799+ * shared objects to thread local
3800+ $(LI Cannot access `@system` or $(D __gshared) variables.)
3801+ $(LI Cannot use $(D void) initializers for:)
3802+ * Pointers/reference types or any type containing them
3803+ * Types that have invariants
3804+ )
3805+
3806+ $(NOTE When indexing or slicing an array, an out of bounds access
38023807 will cause a runtime error.
38033808 )
38043809
0 commit comments