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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 16 10:43:08 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6681

           Summary: bogus duplicate union initialization or overlapping
                    initialization errors
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: fawzi at gmx.ch


--- Comment #0 from Fawzi Mohamed <fawzi at gmx.ch> 2011-09-16 10:42:44 PDT ---
In D1 code like this

{{{

module t;

template MTuple( TList... )
{
    alias TList MTuple;
}

struct V{
    union {
        double[2] cell;
        version(v2) {} else {
            MTuple!(double,double) tuple;
        }
        struct {
            union { double x; double r; }
            union { double y; double g; }
        }
    }

    static const V zero={x:0, y:1};
}

V a=V.zero;

version(v2) {
struct Q {
    union {
        struct {
            double x, y;
        }
        V xyzw;
    }

    const static Q id = { x: 0, y:1 };

}

Q b=Q.id;
}
}}}

fails with duplicate union initialization, which is incorrect.
This happens both with and without -version=v2 which shows that the error is
not just the tuple.
Closely related errors are present also in D2, even if one uses constructors:
{{{

module t;

template MTuple( TList... )
{
    alias TList MTuple;
}

struct V{
    this(double a,double b){
        x=a;
        y=b;
    }
    union {
        double[2] cell;
        version(v2) {} else {
            MTuple!(double,double) tuple;
        }
        struct {
            union { double x; double r; }
            union { double y; double g; }
        }
    }

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

V a=V.zero;

version(v2) {
struct Q {
    union {
        struct {
            double x, y;
        }
        V xyzw;
    }

    immutable static Q id =Q(0,1);

}

Q b=Q.id;
}
}}}

similar errors seem to be very old:

http://www.digitalmars.com/d/archives/digitalmars/D/bugs/6271.html
and there are related or very similar errors are already present in bugzilla:

http://d.puremagic.com/issues/show_bug.cgi?id=4241 which basically uses the
same code as me (omg derived vector structs), but just complains about line
number, seemingly accepting the error (which is bogus imho.
I have also tried to sprinkle around some =void but I just managed to end up
with "Error: no initializer for union".

http://d.puremagic.com/issues/show_bug.cgi?id=1432 (using initializers in the
union)

but this one at least with D1 is a regression from 1.067 at least

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


More information about the Digitalmars-d-bugs mailing list