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


Steven Schveighoffer <schvei...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schvei...@yahoo.com
            Summary|"clear" does not call       |"clear" does not call
                   |destructors on embedded     |destructors on structs
                   |structs                     |embedded in structs


--- Comment #1 from Steven Schveighoffer <schvei...@yahoo.com> 2011-02-28 
11:14:17 PST ---
Your first case is invalid.  Clear depends on the type system:

    auto buf = malloc(size)[0..size];
    emplace!C(buf);
    clear(buf); // here, typeof(buf) == void[], will not call the class version

This does work:

    auto buf = malloc(size)[0..size];
    auto c = emplace!C(buf);
    clear(c);

The second case, I agree it's a bug.  Even clearing a stack-based struct does
not call the embedded dtor:

    S2 s2;
    clear(s2);
    assert(dtorCalled == 1); // fails

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

Reply via email to