Jump to page: 1 2
Thread overview
[Issue 15704] @safe code should not allow copying to/from void[]
[Issue 15704] @safe code should not allow copying of void[]
Jun 13, 2016
Nick Treleaven
[Issue 15704] @safe code should not allow copying into void[]
Jun 14, 2016
Nick Treleaven
Jun 20, 2016
Walter Bright
Mar 18, 2021
Nathan S.
February 18, 2016
https://issues.dlang.org/show_bug.cgi?id=15704

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, safe

--
June 13, 2016
https://issues.dlang.org/show_bug.cgi?id=15704

Nick Treleaven <ntrel-pub@mybtinternet.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ntrel-pub@mybtinternet.com

--- Comment #1 from Nick Treleaven <ntrel-pub@mybtinternet.com> ---
Shouldn't we just disallow all writes to a void[] in safe code?

--
June 14, 2016
https://issues.dlang.org/show_bug.cgi?id=15704

Nick Treleaven <ntrel-pub@mybtinternet.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|@safe code should not allow |@safe code should not allow
                   |copying of void[]           |copying into void[]

--
June 14, 2016
https://issues.dlang.org/show_bug.cgi?id=15704

--- Comment #2 from hsteoh@quickfur.ath.cx ---
It's not just writing to void[] that's the problem. Consider:

----
int[] intArr = [ 1,2,3,4,5 ];
void[] voidArr = intArr; // OK, every array converts to void[]
int*[] ptrArr;
ptrArr.length = 5;
ptrArr[] = voidArr[]; // reinterpret intArr as pointers
ptrArr[0] = 1; // oops
----

Basically, *anything* that leads to reinterpretation of something as pointer values cannot be allowed in @safe.

--
June 14, 2016
https://issues.dlang.org/show_bug.cgi?id=15704

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|@safe code should not allow |@safe code should not allow
                   |copying into void[]         |copying to/from void[]

--
June 14, 2016
https://issues.dlang.org/show_bug.cgi?id=15704

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com

--- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> ---
(In reply to hsteoh from comment #2)
> It's not just writing to void[] that's the problem. Consider:
> 
> ----
> int[] intArr = [ 1,2,3,4,5 ];
> void[] voidArr = intArr; // OK, every array converts to void[]
> int*[] ptrArr;
> ptrArr.length = 5;
> ptrArr[] = voidArr[]; // reinterpret intArr as pointers

Wait, does this really work (I didn't think it did)? If so, isn't it still
implicitly doing this:

(cast(void[])ptrArr)[] = voidArr[];

Which is still writing void data.

--
June 14, 2016
https://issues.dlang.org/show_bug.cgi?id=15704

--- Comment #4 from hsteoh@quickfur.ath.cx ---
Oh, you're right, it doesn't compile because implicit conversion from void[] to int*[] is not allowed.  OK, nevermind what I said, then. :-D

--
June 20, 2016
https://issues.dlang.org/show_bug.cgi?id=15704

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |bugzilla@digitalmars.com
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> ---
https://github.com/dlang/dmd/pull/5877

--
June 21, 2016
https://issues.dlang.org/show_bug.cgi?id=15704

--- Comment #6 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/378e6e3ff01e8e1afd5b5bb97d259ae68918ef9e fix Issue 15704 - @safe code should not allow copying to/from void[]

https://github.com/dlang/dmd/commit/8ed696695c913234d7bed276215c9dcae8a9cc66 Merge pull request #5877 from WalterBright/fix15704

fix Issue 15704 - @safe code should not allow copying to/from void[]

--
June 21, 2016
https://issues.dlang.org/show_bug.cgi?id=15704

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
« First   ‹ Prev
1 2