www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17073] New: Priority clash with `void` default initialization

https://issues.dlang.org/show_bug.cgi?id=17073

          Issue ID: 17073
           Summary: Priority clash with `void` default initialization of
                    struct fields
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: joseph.wakeling webdrake.net

If a struct field is default-initialized to `void` then this will override any
later default initialization of a whole instance of that struct.

For example, in the following code:

//////////////////////////////
struct Inner
{
    uint alpha = void;
    uint beta = 66;
}

struct Outer
{
    Inner inner = Inner(23, 99);
}


void main ()
{
    import std.stdio : writeln;
    Outer outer;
    outer.inner.writeln;
}
//////////////////////////////

... the result with dmd is that `outer.inner` is `Inner(0, 99)` instead of the
expected `Inner(23, 99)`.

Compiling with e.g. LDC produces the expected result of `Inner(23, 99)`.

Note, the issue still appears even if DMD is used with the same frontend
version as LDC.  This therefore appears to be a DMD backend issue.

--
Jan 08 2017