Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing precondition check in forward_list::splice_after #2057

Merged
merged 1 commit into from
Jul 30, 2021

Conversation

CaseyCarter
Copy link
Member

@CaseyCarter CaseyCarter commented Jul 13, 2021

forward_list::splice_after(target_iterator, some_list, before_source_iterator) requires that ++before_source_iterator - the iterator that denotes the element to be removed from some_list and inserted into *this after target_iterator - be dereferenceable. We conventionally don't check preconditions when the result of violation is to dereference a nullptr, since the behavior is nicely predictable, but doing so here avoids confusion about what otherwise seems like a reasonable call as in DevCom-1456054.

@CaseyCarter CaseyCarter added the enhancement Something can be improved label Jul 13, 2021
@CaseyCarter CaseyCarter requested a review from a team as a code owner July 13, 2021 15:56
`forward_list::splice_after(target_iterator, some_list, before_source_iterator)` requires that `++before_source_iterator` - the iterator that denotes the element to be removed from `some_list` and inserted into `*this` after `target_iterator` - be dereferenceable. We conventionally don't check preconditions when the result of violation is to dereference a `nullptr`, since the behavior is nicely predictable, but doing so here avoids confusion about what otherwise seems like a reasonable call as in DevCom-1456054.
@mnatsuhara mnatsuhara self-assigned this Jul 14, 2021
@CaseyCarter CaseyCarter changed the title Add missing precondition check in forward_list::splice_after Add missing precondition check in forward_list::splice_after Jul 14, 2021
@StephanTLavavej StephanTLavavej self-assigned this Jul 29, 2021
@StephanTLavavej StephanTLavavej merged commit 71208b1 into microsoft:main Jul 30, 2021
@StephanTLavavej
Copy link
Member

Thanks for adding this diagnostic and helping users to understand what's happening! 😸 🧠 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
  翻译: