Implementing SmartPtr - compiler bug?
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 27 00:53:04 PDT 2014
just checked this with gdc and dmd head. interesting that
a = a.init;
works the same in gdc and in dmd: just calls destructors for structs.
but doing
a[] = S.init
works different. gdc does the same as in the first case: just calling
destructors for all array elements. but dmd head calls postblits
before destructing for all array elements (and then calls destructors
for this copied elements). i.e.
first case:
destructor: bff51e2b
destructor: bff51e2a
destructor: bff51e29
destructor: bff51e28
second case:
postblit: bff9405c
destructor: bff94028
postblit: bff9405d
destructor: bff94028
postblit: bff9405e
destructor: bff94028
postblit: bff9405f
destructor: bff94028
destructor: bff9405f
destructor: bff9405e
destructor: bff9405d
destructor: bff9405c
besides, dmd calls destructor for the first array element four times
(bff94028).
i think that this is definitely compiler bug. if dmd insists on
postbliting, it should at least call destructors for all array
elements, not only for the first one four times. ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141027/4f0510b7/attachment.sig>
More information about the Digitalmars-d-learn
mailing list