Repository navigation
Conversation
Moving or swapping a basic_pbf_writer that has an open submessage leaves the sub-writer pointing to the moved-from object. In debug builds this later fails with an unrelated assert, in release builds it silently produces a corrupt message. Assert in the move constructor and swap() instead. We also add assert_tests, where a failed assert ends the process and we check for the correct assert being triggered in case of API misuse.
Collaborator
|
A move that only works sometimes isn't great. But I don't have an idea either how to do the move with an open submessage. Regarding the assertion tests: Without looking too much into the details, it seems all rather complex for not many cases. There isn't much need for functions being "noexcept", destructors, move and swap are really the only cases where this is important. What about making all the "noexcept"s for functions with |
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.
Moving or swapping a
basic_pbf_writerthat has an open submessage leaves the sub-writer pointing to the moved-from object. In debug builds this later fails with an unrelated assert, in release builds it silently produces a corrupt message.The "fix" is to assert in the move constructor and swap() instead, and prohibit moving writers with an open submessage.
This PR also adds assertion tests, where a failed assert ends the process and we check for the correct assert being triggered in case of API misuse. This is the first place where we're checking that we fire the correct assertions in case of API misuse, but I think we should extend this pattern to other places to ensure we're correctly hitting them in case of misuse. WDYT, @joto?