[Issue 23444] Can't append non-copyable struct value to an array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 4 12:24:50 UTC 2023


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

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
This seems to be done on purpose, see this comment:
https://issues.dlang.org/show_bug.cgi?id=7579#c5 .

In short, if you concatenate a struct instance with a disabled postblit you
subject yourself to the possibility of the runtime doing copies behind your
back (for example, when reallocations happen). This seems pretty nasty because
the alternative would be to accept this code and then either do copies that do
not call the postblit behind the scenes or have some druntime internal failures
(provided that the hooks are properly templated).

--


More information about the Digitalmars-d-bugs mailing list