Avoid stdext::checked_array_iterator
for modern MSVC
#1205
+1
−1
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.
I work on MSVC's STL, and we'd like you to stop using one of our old non-Standard extensions, as we're working towards eventually removing it.
In VS 2005, MSVC's non-Standard extension
stdext::checked_array_iterator
was added to provide guaranteed bounds checking. At the same time, MSVC began emitting Microsoft "deprecation" warnings for using raw pointers as output iterators.In VS 2017 15.8 (
_MSC_VER
1915
; see our handy decoder table), we stopped emitting those Microsoft "deprecation" warnings for using raw pointers as output iterators. Those warnings were incredibly annoying since they warned about perfectly correct, Standard-conforming code, and led users to generally disregard and silence such warnings. Also, the library was never the right place to implement them because of insufficient context. Instead, we began encouraging wider use of static analysis, which has sufficient context to emit better warnings about writing too many elements into a raw pointer. See our old blog post STL Features and Fixes in VS 2017 15.8 for more info. (This was internal MSVC-PR-120709.)In VS 2022 17.8 (
_MSC_VER
1938
), we began emitting proper Microsoft deprecation warnings for thestdext::checked_array_iterator
family, as this has been superseded not only by static analysis but also by C++20std::span
and downlevel-availablegsl::span
. ("Proper", in this case, because this is about actual Microsoft machinery.) These warnings were initially emitted for/std:c++17
and later, as a way to initially mitigate their impact while encouraging an ecosystem cleanup. (This was microsoft/STL#3818.)In the upcoming VS 2022 17.11, we are unconditionally deprecating the
stdext::checked_array_iterator
family, as we're getting serious about eventual removal. (This was microsoft/STL#4605.)In this PR, because Bond apparently supports compilers down to VS 2015, I'm refining the guard to use
stdext::checked_array_iterator
for MSVC older than VS 2017 15.8, where avoiding those "raw pointers as output iterators" warnings was necessary. For all recent MSVC versions, the portable (and still bounds-checked by your logic!) codepath is selected. In the long term, you may want to consider using C++20std::span
or taking a dependency ongsl::span
, or similar changes (e.g. upgrading builtin arrays tostd::array
s, etc.).