Repository navigation
Clone every item before clearing a Stack, Queue or ConcurrentQueue in DeepCloneFrom [patch] - #126
Merged
Conversation
… DeepCloneFrom [patch] The Stack<T>, Queue<T> and ConcurrentQueue<T> overloads of DeepCloneFrom cleared the destination and cloned inside the refill loop, so an item whose DeepClone threw left the destination holding part of the source with its own contents gone: the #90 failure, brought back by overloads added on a parallel branch. They now clone every item first, through a shared CloneAll helper, and touch the destination only once all clones have succeeded, as the ConcurrentStack<T> overload already did. DeepCloneFromExceptionSafetyTests covers all four types. Fixes #124 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5fUnJtnsd89SqCrfW
|
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #124
What was wrong
#115 added
DeepCloneFromoverloads forStack<T>,Queue<T>andConcurrentQueue<T>. They cleared the destination first and then cloned each item while refilling it. If an item'sDeepClonethrew, the destination was left holding part of the source, with its own contents gone. That is the #90 failure, brought back on these types.What changed
CloneAllhelper snapshots the source and deep clones every item, in order.destonly after every clone has succeeded. TheConcurrentStack<T>overload already worked this way and is unchanged.DeepCloneFromExceptionSafetyTestsnow covers all four types. When the second item's clone throws, each test checks that the destination keeps its original contents in the original pop or dequeue order.Tests
InPlaceStackQueueTestsfor order and self-clone.Stack,QueueandConcurrentQueuetests fail. TheConcurrentStacktest passes either way and is there as a guard.Generated by Claude Code