Bug 9691 – Static void arrays are not documented

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-11T12:08:00Z
Last change time
2014-12-06T16:16:41Z
Keywords
pull
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2013-03-11T12:08:29Z
There is no documentation stating how static void arrays are implemented. In particular, what is their actual element size? It seems they're byte-sized: void main() { byte[2] x; int[2] y; void[2] a = x; // ok void[2] b = y; // runtime error: 8 bytes does not fit into 2 bytes } But this needs to be documented. The last statement should probably also be a compile-time error.
Comment #1 by hsteoh — 2013-03-15T10:41:30Z
I don't like the concept of void[]. It makes me think the element size is 0, and therefore the array is always 0-sized. But it seems the element size of void[] is 1. So then why not ubyte[]? That's basically what it is: you're treating the data as an array of bytes instead of an array of whatever other type it may have been. (Yes an unsafe cast is needed but you're already doing that implicitly by passing T[] to void[] in the first place.)
Comment #2 by andrej.mitrovich — 2013-03-17T12:59:25Z
(In reply to comment #1) > I don't like the concept of void[]. Well the theory is the GC would avoid scanning ubyte[] for pointers unlike void[]. I don't know if that's true or not, it's been mentioned in the newsgroups a few times.
Comment #3 by hsteoh — 2014-12-05T19:55:03Z
Comment #4 by andrej.mitrovich — 2014-12-05T20:20:48Z
(In reply to hsteoh from comment #3) > https://github.com/D-Programming-Language/dlang.org/pull/715 Note that I was also asking for the documentation of fixed-length (static) void arrays, not just plain void dynamic arrays. :)
Comment #5 by hsteoh — 2014-12-05T20:36:57Z
Point taken. I'll update the PR. :-)
Comment #6 by hsteoh — 2014-12-05T21:09:25Z
Updated.
Comment #7 by github-bugzilla — 2014-12-05T22:36:23Z
Commit pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/436291ba70e4f9abd7b845825b22fb455d3f721a Merge pull request #715 from quickfur/issue9691 Issue 9691: document void[] arrays.
Comment #8 by hsteoh — 2014-12-05T22:39:07Z
Hooray! Close this bug now, or wait for the GC guarantee issue to be fixed first?
Comment #9 by andrej.mitrovich — 2014-12-06T00:22:27Z
(In reply to hsteoh from comment #8) > Hooray! Close this bug now, or wait for the GC guarantee issue to be fixed > first? GC seems to be a hot potato right now, we shouldn't let it block these needed doc fixes. :)
Comment #10 by github-bugzilla — 2014-12-06T16:16:41Z
Commit pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/a6f3dcc6df3edbe9f02e66f8a16b78ce1766c7c8 Merge pull request #716 from quickfur/issue9691b Better wording about difference between void[] and ubyte[].