December 16, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3622

           Summary: Nested structs as default function arguments not
                    initialized
           Product: D
           Version: 2.036
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: tomeksowi@gmail.com


--- Comment #0 from Tomasz Sowiński <tomeksowi@gmail.com> 2009-12-16 13:44:35 PST ---
Strangely enough it happens only if the nested struct is forward referenced. Looks like the default argument is not initialized at all in these cases.

Testcase (should pass):

struct Strukt {
    int pole;
    Wsk wsk;

    this(int pole, Wsk wsk = Wsk()) {
        this.pole = pole;
        this.wsk = wsk;
    }

    static Wsk zla_funkcja(uint i, Wsk wsk = Wsk()) {
        return wsk;
    }

    struct Wsk {
        Strukt* w;
    }

    static Wsk funkcja(uint i, Wsk wsk = Wsk()) {
        return wsk;
    }
}


void main() {
    auto ok = Strukt.funkcja(7);
    assert(!ok.w);  // passes

    auto zly = Strukt.zla_funkcja(7);
    assert(!zly.w);     // boom!

    auto s = Strukt(6);
    assert (!s.wsk.w);  // boom!
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 08, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3622


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |FIXED


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-12-08 04:44:34 PST ---
Fixed DMD2.038.

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