Bug 4213 – Strange behaviour with static void[] arrays
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
All
Creation time
2010-05-20T12:13:00Z
Last change time
2014-02-15T02:17:07Z
Keywords
diagnostic, rejects-valid
Assigned to
nobody
Creator
nfxjfg
Comments
Comment #0 by nfxjfg — 2010-05-20T12:13:59Z
This code always worked:
struct X {
union {
void[] a;
void[9] b;
}
}
However, if you remove the union (so that a, b are direct struct members), it stops working and outputs "Error: integral constant must be scalar type, not void" (without line number information!). It also stops compiling if you remove the "a" member.
It also generates a wrong .sizeof for the struct (12 instead of 9*4). Not sure what exactly is going on.
Comment #1 by nfxjfg — 2010-05-20T12:16:10Z
Never mind that bit about the struct's size, b is 9 bytes, aligned on 4 = 12 bytes. Correct.
Comment #2 by bearophile_hugs — 2010-05-20T12:35:51Z
Note that this compiles on v2.046, but it stops compiling if you remove the =void, so that problem can be by design:
void main() {
void[1] a = void;
}