On 18.02.2016 20:17, Era Scarecrow wrote:
On Thursday, 18 February 2016 at 18:41:25 UTC, Steven Schveighoffer wrote:
On 2/18/16 1:30 PM, Timon Gehr wrote:
No problem here. There is no way to assign to a void[] without doing 2.

foo(void[] arr)
{
   void[] arr2 = [1234, 5678, 91011];
   arr[] = arr2[0 .. arr.length];
}

  Since void throws away type information (and all the safety related to
it), would it be easier to simply require @safe code can't cast
implicitly to void? It seems like explicit casting would take care of
most of this, or disallowing to/from void converting period while in
@safe code.

The conversion is fine. It just throws away type information. There's no way to soundly type-check the block assignment after that, so that's the operation that should be disallowed. This also prevents @safe code from mutating untyped memory that was passed through from @system code without preventing it to pass the block back to @trusted code.

Reply via email to