Result location semantics provide footgun for recursive data structures #6216
Labels
use case
Describes a real use case that is difficult or impossible, but does not propose a solution.
Milestone
When writing and reading a structure at the same time, result semantics will destroy information:
This example shows that the value copied by
moveToHeap(root)
is corrupted and is a copy of the temporary constructed, but has a different address.https://zig.godbolt.org/z/571T4W
A simple workaround is this:
The text was updated successfully, but these errors were encountered: