https://gcc.gnu.org/g:08530be2593c2f1f5ce15fe3e8a2524b9f52fc6e
commit r16-4090-g08530be2593c2f1f5ce15fe3e8a2524b9f52fc6e Author: Jonathan Wakely <jwak...@redhat.com> Date: Wed Sep 24 14:37:37 2025 +0100 libstdc++: Check feature test macro for robust_nonmodifying_seq_ops We should check the relevant feature test macro instead of just the value of __cplusplus. Also add a comment explaining why the __cplusplus check guarding __sample *can't* be changed to check __glibcxx_sample (because __sample is also used in C++14 by std::experimental::sample, not only by C++17 std::sample). libstdc++-v3/ChangeLog: * include/bits/stl_algo.h: Check robust_nonmodifying_seq_ops feature test macro instead of checking __cplusplus value. Add comment to another __cplusplus check. * include/bits/stl_algobase.h: Add comment to #endif. Diff: --- libstdc++-v3/include/bits/stl_algo.h | 6 +++--- libstdc++-v3/include/bits/stl_algobase.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 78c63e79a279..b296e12cf0f8 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -3516,7 +3516,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) __gnu_cxx::__ops::__iter_comp_iter(__pred)); } -#if __cplusplus > 201103L +#if __glibcxx_robust_nonmodifying_seq_ops // C++ >= 14 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr template<typename _ForwardIterator1, typename _ForwardIterator2, @@ -3635,7 +3635,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) return std::__is_permutation(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_comp_iter(__pred)); } -#endif // C++14 +#endif // __glibcxx_robust_nonmodifying_seq_ops #ifdef __glibcxx_clamp // C++ >= 17 /** @@ -5828,7 +5828,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO } #endif // C++11 -#if __cplusplus >= 201402L +#if __cplusplus >= 201402L // C++17 std::sample and C++14 experimental::sample /// Reservoir sampling algorithm. template<typename _InputIterator, typename _RandomAccessIterator, typename _Size, typename _UniformRandomBitGenerator> diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 820091aee2dc..022668076138 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -2090,7 +2090,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); } -#endif +#endif // __glibcxx_robust_nonmodifying_seq_ops _GLIBCXX_END_NAMESPACE_ALGO