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: nob...@puremagic.com
        ReportedBy: tomeks...@gmail.com


--- Comment #0 from Tomasz SowiƄski <tomeks...@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: -------

Reply via email to