Re: arr.ptr, @safe and void*

2016-06-16 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 20:33:54 UTC, Steven Schveighoffer wrote: It could probably do this. Dereferencing a void * isn't valid, so it kind of has the same effect. However, there are many functions which take void * and do write to/read from the data pointing at it (e.g. memcpy). These

Re: arr.ptr, @safe and void*

2016-06-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/15/16 4:08 PM, Nick Treleaven wrote: On Wednesday, 15 June 2016 at 17:35:49 UTC, Steven Schveighoffer wrote: On 6/15/16 6:32 AM, Nick Treleaven wrote: My question is: would returning void* instead really be unsafe, i.e. is there a way of dereferencing it in safe code? (I'm not thinking

Re: arr.ptr, @safe and void*

2016-06-15 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 17:35:49 UTC, Steven Schveighoffer wrote: On 6/15/16 6:32 AM, Nick Treleaven wrote: My question is: would returning void* instead really be unsafe, i.e. is there a way of dereferencing it in safe code? (I'm not thinking about holes in @safe, but ways by

Re: arr.ptr, @safe and void*

2016-06-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/15/16 6:32 AM, Nick Treleaven wrote: Hi, Walter's made a fix for arr[$..$].ptr being unsafe to dereference - .ptr will be @system: https://github.com/dlang/dmd/pull/5860 A referenced druntime pull mentioned having a safe wrapper for ..ptr that allows comparison of the pointer value, but

arr.ptr, @safe and void*

2016-06-15 Thread Nick Treleaven via Digitalmars-d-learn
Hi, Walter's made a fix for arr[$..$].ptr being unsafe to dereference - .ptr will be @system: https://github.com/dlang/dmd/pull/5860 A referenced druntime pull mentioned having a safe wrapper for .ptr that allows comparison of the pointer value, but does not allow dereference. The wrapper