Steven Schveighoffer <> changed:

           What    |Removed                     |Added
                 CC|                            |
            Summary|"clear" does not call       |"clear" does not call
                   |destructors on embedded     |destructors on structs
                   |structs                     |embedded in structs

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

    auto buf = malloc(size)[0..size];
    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);

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

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

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to