Bug 2386 – Array of forward referenced struct doesn't compile

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-10-02T09:49:00Z
Last change time
2015-06-09T01:20:18Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
dfj1esp02
Blocks
340, 2654

Comments

Comment #0 by dfj1esp02 — 2008-10-02T09:49:14Z
struct BB { Item[1] aa; //struct tmp.Item no size yet for forward reference } struct CC { Item aa; //ok } struct Item { byte data; }
Comment #1 by r.sagitario — 2010-03-27T06:17:13Z
Here's a patch that simply invokes the semantics of the forward referenced struct. Index: struct.c =================================================================== --- struct.c (revision 421) +++ struct.c (working copy) @@ -115,6 +115,8 @@ //printf("AggregateDeclaration::size() = %d\n", structsize); if (!members) error(loc, "unknown size"); + if (sizeok != 1 && scope) + semantic(NULL); if (sizeok != 1) { error(loc, "no size yet for forward reference"); //*(char*)0=0; This patch also fixes #2654
Comment #2 by bugzilla — 2010-05-10T13:39:09Z
changeset 429
Comment #3 by bearophile_hugs — 2010-05-15T17:53:20Z
This is fixed in v2.046 and v1.061.