4213 – Strange behaviour with static void[] arrays

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4213 - Strange behaviour with static void[] arrays
Summary: Strange behaviour with static void[] arrays
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: diagnostic, rejects-valid
Depends on:
Blocks:
Reported: 2010年05月20日 12:13 UTC by nfxjfg
Modified: 2014年02月15日 02:17 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description nfxjfg 2010年05月20日 12:13:59 UTC
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 nfxjfg 2010年05月20日 12:16:10 UTC
Never mind that bit about the struct's size, b is 9 bytes, aligned on 4 = 12 bytes. Correct.
Comment 2 bearophile_hugs 2010年05月20日 12:35:51 UTC
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;
}
Comment 3 Walter Bright 2010年05月20日 22:19:19 UTC
improved error message with changeset 496


AltStyle によって変換されたページ (->オリジナル) /