Skip to content

Drop usage of non-Standard stdext - #1339

Merged
weidai11 merged 2 commits into
weidai11:masterfrom
StephanTLavavej:remove-stdext
Feb 27, 2026
Merged

weidai11 merged 2 commits into
weidai11:masterfrom
StephanTLavavej:remove-stdext

Conversation

@StephanTLavavej

Copy link
Copy Markdown
Contributor

Fixes #1250.

I'm the primary maintainer of MSVC's C++ Standard Library. We build popular open-source projects, including cryptopp, with development builds of our toolset in order to find and fix regressions in the compiler and libraries before they can ship and cause trouble for you. This also allows us to provide advance notice of breaking changes, which is the case here.

Long ago, we used to emit incredibly obnoxious warnings about using raw pointers as output iterators, which could be avoided by using our non-Standard stdext::checked_array_iterator or stdext::unchecked_array_iterator. Those warnings were removed in VS 2017 15.8, released in August 2018.

Later, we deprecated these stdext iterators for C++17 and later in VS 2022 17.8 in November 2023, as reported by #1250. We then strengthened the deprecation to be unconditional (i.e. also C++14 mode) in VS 2022 17.11 in August 2024.

They're still present (and deprecated) in the MSVC Build Tools 14.50 which will be shipping in VS 2026 18.0. However, I've completely removed them in the MSVC Build Tools 14.51 (with microsoft/STL#5817), which will ship in a future update to VS 2026 18.x.

Now that the stdext iterators are no longer needed to avoid obnoxious warnings, their usage can simply be removed, calling Standard algorithms with raw pointers directly.

I also took this opportunity to remove a strange-looking call to stdext::unchecked_mismatch that appeared to be used for only certain old versions of MSVC, although I don't understand what was happening there (I've worked on the STL since 2007 and I've never seen such an algorithm in the stdext namespace). In any event, calling Standard mismatch is the right thing to do.

@irwir

irwir commented Nov 7, 2025 •

Copy link
Copy Markdown
Contributor

According to the crypto++ site, the current version 8.9.0 could be built with Visual Studio 2003 - 2022.
The issue #1250 makes references to much older #123 and #496.
Building with Visual C 6.0 is not supported now, but VS 2005 still is allowed and might need those stdext workarounds.
Therefore, the suggestion is to keep conditional compilation blocks, only add upper limit for the version. For example:
integer.cpp

#if (CRYPTOPP_MSC_VERSION >= 1500) && (CRYPTOPP_MSC_VERSION < 1938)
		std::reverse_copy(encodedInteger, encodedInteger+byteCount,
			stdext::make_checked_array_iterator(block.begin(), block.size()));
#else
		std::reverse_copy(encodedInteger, encodedInteger+byteCount, block.begin());
#endif

zdeflate.cpp

#if defined(_STDEXT_BEGIN) && !(defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION < 1400 || CRYPTOPP_MSC_VERSION >= 1600)) && !defined(_STLPORT_VERSION)
				stdext::unchecked_mismatch
#else
				std::mismatch
#endif
#if (CRYPTOPP_MSC_VERSION >= 1600) && (CRYPTOPP_MSC_VERSION < 1938)
				(stdext::make_unchecked_array_iterator(scan)+3, stdext::make_unchecked_array_iterator(scanEnd), stdext::make_unchecked_array_iterator(match)+3).first - stdext::make_unchecked_array_iterator(scan));
#else
				(scan+3, scanEnd, match+3).first - scan);
#endif

This code compiles quietly in the current VS 2022 17.14.19.

@StephanTLavavej

Copy link
Copy Markdown
Contributor Author

Sure, an upper limit to the MSVC version would be entirely reasonable.

Coralesoft added a commit to cryptopp-modern/cryptopp-modern that referenced this pull request Nov 30, 2025
Remove Microsoft-specific stdext::checked_array_iterator,
stdext::unchecked_array_iterator, and stdext::unchecked_mismatch.

These were workarounds for old MSVC warnings that were removed in
VS 2017 15.8 (August 2018). The stdext iterators are deprecated
since VS 2022 17.8 and will be completely removed in VS 2026 18.x.

Based on weidai11/cryptopp#1339

Co-Authored-By: Stephan T. Lavavej <stl@microsoft.com>
Coralesoft added a commit to cryptopp-modern/cryptopp-modern that referenced this pull request Nov 30, 2025
@weidai11

Copy link
Copy Markdown
Owner

Thanks for the PR, Stephan. Since you agree with irwir's proposal to add an upper limit to the MSVC version, could you please go ahead and update this pull request with those changes?

@StephanTLavavej

Copy link
Copy Markdown
Contributor Author

Pushed. I've retained my unconditional use of std::mismatch because I cannot possibly believe that stdext::unchecked_mismatch existed in my product without me knowing. (std::mismatch is obviously always available, and giving it my unchecked_array_iterators always avoided the "deprecation" warnings, so this will compile cleanly even in those old versions.)

@weidai11
weidai11 merged commit ee40310 into weidai11:master Feb 27, 2026
@StephanTLavavej
StephanTLavavej deleted the remove-stdext branch February 27, 2026 14:56
weidai11 pushed a commit that referenced this pull request Feb 27, 2026
GT-610 added a commit to GT-610/csgo-gc that referenced this pull request Jun 24, 2026
MSVC 19.51 (VS 2026 18.x) completely removed stdext::make_checked_array_iterator and stdext::make_unchecked_array_iterator, which were previously only deprecated. The cryptopp CRYPTOPP_8_9_0 release tag still uses these removed functions.

Enable CRYPTOPP_USE_MASTER_BRANCH to fetch cryptopp from master, which includes the upstream fix (weidai11/cryptopp#1339) that replaces all stdext usage with standard C++ equivalents. Remove the now-unnecessary _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING workaround.
manxorist added a commit to OpenMPT/openmpt that referenced this pull request Aug 13, 2026
manxorist added a commit to OpenMPT/openmpt that referenced this pull request Aug 13, 2026
surepy added a commit to surepy/tf2_bot_detector that referenced this pull request Oct 7, 2026
causes build failures: see weidai11/cryptopp#1339
my workflow honestly lives in 2022 anyway but i wanted to give windows-latest a try.
GuriKristine pushed a commit to PionsLab/cryptopp_upstream that referenced this pull request Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compile warnings in VS 2022 17.8.0 - stdext::make_checked_array_iterator stdext::make_unchecked_array_iterator beeing deprecated

3 participants