Thread overview
[Issue 22552] moveEmplace wipes context pointer of nested struct contained in non-nested struct
Nov 29, 2021
kinke
Nov 30, 2021
Stanislav Blinov
Nov 30, 2021
Dlang Bot
Jan 06, 2022
Dlang Bot
November 29, 2021
https://issues.dlang.org/show_bug.cgi?id=22552

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #1 from kinke <kinke@gmx.net> ---
(In reply to Stanislav Blinov from comment #0)
> That's because moveEmplace simply blits NotNested.init into a. Instead it probably should move things fieldwise and avoid wiping context pointers in fields that are nested structs.

Blitting the whole thing at once is still fine, but the problem arises with the T.init reset of the source instance. It would probably really have to reset the fields recursively in order not to clear any context pointers. There should IMO still be a fast path for the very common case of no nested context pointers.

--
November 30, 2021
https://issues.dlang.org/show_bug.cgi?id=22552

--- Comment #2 from Stanislav Blinov <stanislav.blinov@gmail.com> ---
Yes, bulk bit copy into destination would be fine, it's initializer blit that causes a problem. Although, if we're going to recursively inspect structs and static arrays to find any nested struct members, might as well make that recursion also emit the blits. Also, I have another enhancement in mind that could require recursive reflection: IMO, moving anything that has a pointer should require wiping the source (except for context pointers). I'll file that separately.

Also, there's the question of const fields... Bleh. I'll make the pull for this issue later today, and we can discuss the details there.

--
November 30, 2021
https://issues.dlang.org/show_bug.cgi?id=22552

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@radcapricorn created dlang/druntime pull request #3638 "Fix Issue 22552 - moveEmplace wipes context pointer of nested struct …" fixing this issue:

- Fix Issue 22552 - moveEmplace wipes context pointer of nested struct contained in non-nested struct

https://github.com/dlang/druntime/pull/3638

--
January 06, 2022
https://issues.dlang.org/show_bug.cgi?id=22552

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/druntime pull request #3638 "Fix Issue 22552 - moveEmplace wipes context pointer of nested struct …" was merged into master:

- 6fee027668fb8905e9c22cb5532dfc1fd4f6c478 by Stanislav Blinov:
  Fix Issue 22552 - moveEmplace wipes context pointer of nested struct
contained in non-nested struct

https://github.com/dlang/druntime/pull/3638

--