[Issue 16131] A struct is being copied unnecessarily when initialized
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Jun 7 04:36:42 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16131
Ketmar Dark <ketmar at ketmar.no-ip.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |ketmar at ketmar.no-ip.org
Resolution|--- |INVALID
--- Comment #2 from Ketmar Dark <ketmar at ketmar.no-ip.org> ---
structs are value types, so compiler is free to move 'em (i.e. just memcpy
without calling postblit/dtor/ctor). this is a feature of value types. that's
why you should never store a pointer to stack-allocated struct, even if it is
guaranteed that the pointer will not outlive the struct itself.
i'm closing this bug as INVALID, but feel free to open an ER with the request
for better documentation for copy/move semantic.
--
More information about the Digitalmars-d-bugs
mailing list