D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12799 - Forward reference to nested enum with struct.sizeof
Summary: Forward reference to nested enum with struct.sizeof
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 minor
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks: 340
  Show dependency treegraph
 
Reported: 2014-05-25 07:24 UTC by anonymous4
Modified: 2015-06-17 21:01 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description anonymous4 2014-05-25 07:24:25 UTC
struct A
{
  enum C=A.sizeof;
  enum D=C; //Error: forward reference of variable C
  int a;
}
Comment 1 anonymous4 2014-05-25 07:51:23 UTC
I first wanted to implement a variable-sized struct this way.

struct Region
{
	enum fullSize=128, head=Region.sizeof/size_t.sizeof;
	enum capacity=fullSize-head;

	Region* prev;
	int count;

	void*[] allocations()
	{
		return all[0..count];
	}
	void put(void* data)
	{
		assert(count<capacity);
		all[count]=data;
		count++;
	}
	void*[] all(void* data)
	{
		void* b=cast(void**)&this+head;
		return b[0..capacity];
	}
}

Well, it's not really variable-sized, so I just declared a fixed-sized array in it.
Comment 2 anonymous4 2014-05-30 17:31:25 UTC
Though a big fixed-sized array in a struct creates a big init value.
Comment 4 github-bugzilla 2015-03-25 08:09:37 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/945b754bd1084b77f09da55f5cc9c1f2ea5e89ca
fix Issue 12799 - Forward reference to nested enum with struct.sizeof

https://github.com/D-Programming-Language/dmd/commit/0358a7d216fd75eabea5782b682f6807ce1dde0b
Merge pull request #4467 from 9rnsr/fix12799

Issue 12799 - Forward reference to nested enum with struct.sizeof
Comment 5 github-bugzilla 2015-06-17 21:01:42 UTC
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/945b754bd1084b77f09da55f5cc9c1f2ea5e89ca
fix Issue 12799 - Forward reference to nested enum with struct.sizeof

https://github.com/D-Programming-Language/dmd/commit/0358a7d216fd75eabea5782b682f6807ce1dde0b
Merge pull request #4467 from 9rnsr/fix12799