KEMBAR78
Partially implement P3697R1 Minor Additions To Standard Library Hardening by frederick-vs-ja · Pull Request #5650 · microsoft/STL · GitHub
Skip to content

Conversation

@frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Jul 20, 2025

This PR completes hardening introduced by WG21-P3697R1. Towards #5300.

Hardened preconditions are checked when either _MSVC_STL_HARDENING_MEOW or _ITERATOR_DEBUG_LEVEL != 0.

Notes:

  • The implementation is still partial due to lack of contracts.
  • view_interface was already hardened in STL Hardening #5274.
  • Most checks of common_iterator and counted_iterator were already done, and this PR only makes the checks enabled with hardening options.
  • The hardened preconditions of basic_stacktrace::operator[] is checked by default via vector::operator[], so this PR only enable the additional check when the check of vector::operator[] is turned off.
  • Checks of shared_ptr::operator[], basic_stacktrace::current, common_iterator's constructor, common_iterator::operator==, iter_move(counted_iterator), and iter_swap(counted_iterator) are newly added in this PR.
  • A new test entry, GH_005090_stl_hardening_cxx20_iterators, is added for C++20 (and potentially later) iterators with iter_move and/or iter_swap being hidden friends. These iterators are permanently incompatible with /permissive.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner July 20, 2025 09:18
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Jul 20, 2025
@frederick-vs-ja

This comment was marked as resolved.

@StephanTLavavej StephanTLavavej added the cxx26 C++26 feature label Jul 22, 2025
@StephanTLavavej StephanTLavavej self-assigned this Jul 22, 2025
@StephanTLavavej
Copy link
Member

Thanks! 😻 I pushed numerous small changes, the only significant one being to exceptional_iterator's ctor/assign. Please double-check.

@StephanTLavavej StephanTLavavej removed their assignment Aug 24, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Aug 24, 2025
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Aug 25, 2025
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 99cdd88 into microsoft:main Aug 25, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Aug 25, 2025
@StephanTLavavej
Copy link
Member

💎 💎 💎

@frederick-vs-ja frederick-vs-ja deleted the pre-contract-p3697r1 branch August 26, 2025 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cxx26 C++26 feature

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants