[Issue 6681] bogus duplicate union initialization or overlapping initialization errors

2012-02-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6681


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 CC||yebbl...@gmail.com


--- Comment #2 from yebblies yebbl...@gmail.com 2012-02-01 22:58:33 EST ---
Ok, the first test case reduces to this:

struct V{
union {
double[2] cell;
double x;
}

static immutable V zero=V(0,1);
}

The problem being that the struct literal gets turned into:
  this(a, b) { cell = 0; x = 1; }
ie. it passes the first argument to the first member, and the second argument
to the second.

This is sort of what I'd expect to happen, but the error message is completely
valid for what it's trying to do.  If anyone has a better idea of how struct
literals should map to unions, please open another bug report about it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 6681] bogus duplicate union initialization or overlapping initialization errors

2011-10-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6681


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com


--- Comment #1 from Walter Bright bugzi...@digitalmars.com 2011-10-24 
20:57:25 PDT ---
There have been several patches to 'fix' struct/union initialization.
Evidently, we need to step back a bit and rethink/reengineer it. Something
along the lines of:

1. Create a list of all the fields, in lexical order. Each field will have a
beginning offset and an ending offset. One field 'overlaps' another if its
offset range overlaps the other.

2. Examine list of initializers. Unnamed initializers will be associated with a
field as follows:
1. if it's the first initializer, it's the first field. Done.
2. start with the previous field that was initialized. Move forward through
the field list and pick the first field that does not overlap with that
previous field. That will be the field associated with that initializer.

3. If any initialized field overlaps with any other initialized field, error.

4. Go back through the field list again, in order. If a field does not have an
initializer, and does not overlap with any other initialized field, assign it
the default initializer.

At this point, I wish to defer this to the next update.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---