[PATCH][_GLIBCXX_DEBUG] Enhance COW basic_string checks
François Dumont
frs.dumont@gmail.com
Fri Jul 3 19:50:18 GMT 2026
Gentle reminder, any chance to review it ?
On 6/15/26 07:07, François Dumont wrote:
> Hi
>
> libstdc++: [_GLIBCXX_DEBUG] Improve COW basic_string checks
>
> Put the __glibcxx_requires_valid_range checks at public member level
> so that diagnostics are giving directly the invoked member name.
>
> Add the std::_RequireInputIter constraints on members taking template
> iterator range to avoid the "do the right thing" ambiguity without
> the help of __is_integer.
>
> libstdc++v3/ChangeLog:
>
> * include/bits/cow_string.h
> (basic_string::_M_replace): New.
> (basic_string(_InputIterator, _InputIterator, const
> _Alloc&): Add
> std::_RequireInputIter constraint and
> __glibcxx_requires_valid_constructor_range
> check.
> (basic_string::append(_InputIte, _InputIte): Add
> std::_RequireInputIter
> constraint and __glibcxx_requires_valid_range check. Call
> _M_replace.
> (basic_string::assign(_InputIte, _InputIte): Likewise.
> (basic_string::insert(iterator, _InputIte, _InputIte)):
> Likewise.
> (basic_string::replace(iterator, iterator, _InputIte,
> _InputIte)): Likewise.
> [__cplusplus >= 201103L](basic_string::_S_construct): New.
> (basic_string::_M_replace_dispatch(iterator, iterator,
> _InputIte, _InputIte,
> __false_type)): Remove __glibcxx_requires_valid_range check.
> * include/debug/debug.h
> (__glibcxx_requires_valid_constructor_range): New.
>
> Tested under Linux x86_64 with _GLIBCXX_USE_CXX11_ABI=0 and
> _GLIBCXX_DEBUG.
>
> Note that there is a double requires-valid-range check when _M_replace
> is being called because of the temporary basic_string instantiation.
>
> Ok to commit ?
>
> François
More information about the Libstdc++
mailing list