[Issue 9732] Do not call opAssign() for the first assignment to member in the constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 16 22:25:41 PDT 2013


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



--- Comment #2 from Ali Cehreli <acehreli at yahoo.com> 2013-03-16 22:25:36 PDT ---
I think you are right because the .init state of a member may not be as simple
as one thinks. Although OuterStruct.inner must be known at compile time, it may
have a non-trivial destructor that needs to be called:

struct Inner
{
    ~this()
    {
        // ... not-trivial destructor ...
    }

    // ...
}

struct OuterStruct
{
    Inner inner = Inner(specialInitValue);    // <-- compile-time .init

    this(int i)
    {
        this.inner = Inner(i);    // <-- further assignment
    }
}

Blitting the rvalue on top of OuterStruct.inner would not be right in that
case.

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


More information about the Digitalmars-d-bugs mailing list