[Issue 18474] Postblit not working in shared structs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 22 06:09:05 UTC 2018


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

Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang at jmdavisProg.co
                   |                            |m

--- Comment #1 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
I don't think that this is actually a bug. shared isn't inferred by anything
let alone postlbit constructors, and fundamentally, the same code does not work
as both thread-local and shared. And I don't know how safe copying is with
shared in general. The copy needs to be thread-safe for it to work properly,
but there are no mutexes involved when the struct is blitted. A mutex could
then be used in the postblit constructor to protect it, but that gets a bit
funny, because really, the it needs to be a mutex shared with the struct being
copied in order to properly protect the shared reference types, and once the
blitting has happened, you're mutating a copy. But fundamentally, I don't know
that blitting the struct can even work properly with shared, since that needs
to either be atomic or use a mutex, and AFAIK, it does neither.

Really, I think that copying structs is one of those areas where shared has not
been fleshed out as well as it needs to be.

--


More information about the Digitalmars-d-bugs mailing list