D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2386 - Array of forward referenced struct doesn't compile
Summary: Array of forward referenced struct doesn't compile
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks: 340 2654
  Show dependency treegraph
 
Reported: 2008-10-02 09:49 UTC by anonymous4
Modified: 2015-06-09 01:20 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description anonymous4 2008-10-02 09:49:14 UTC
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 Rainer Schuetze 2010-03-27 06:17:13 UTC
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 Walter Bright 2010-05-10 13:39:09 UTC
changeset 429
Comment 3 bearophile_hugs 2010-05-15 17:53:20 UTC
This is fixed in v2.046 and v1.061.