[Issue 16197] Constructors/postblits and destructors don't match up for array initialisation

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jun 23 12:12:14 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16197

Max Samukha <maxsamukha at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxsamukha at gmail.com

--- Comment #7 from Max Samukha <maxsamukha at gmail.com> ---
(In reply to Steven Schveighoffer from comment #6)

> 
> BTW, the postblit for the -1 values seems incorrect...

Definitely incorrect (dmd):

struct Elem {
    int x = -1;
    this(this) { writeln("POSTBLIT ", x); }
    ~this()    { writeln("DTOR "    , x); }
}

struct Ctr {
    Elem[1] arr;
}

void main() {
    auto p = Ctr();
}

prints:

POSTBLIT 
DTOR 


Should be either two destructors or no postblit. For "Elem arr" instead of
"Elem[1] arr", only the destructor is correctly called once.

--


More information about the Digitalmars-d-bugs mailing list