Looks like another occurrence of the lack of maintenance of
__gnu_debug::basic_string, sorry.
Here is I think the patch to fix it.
libstdc++: [_GLIBCXX_DEBUG] Constrain basic_string iterator constructor
Constrain __gnu_debug::basic_string(_Ite, _Ite, const _Alloc&) _Ite
template
parameter so that it is an iterator type.
libstdc++-v3/ChangeLog:
* include/debug/string
[__cplusplus >= 201103L](basic_string(_Ite, _Ite, const
_Alloc&)): Add
std::_RequireInputIter<_Ite> template parameter.
Almost simple enough to commit myself but in this kind of situation I
prefer to ask.
Ok to commit ?
François
On 3/9/26 12:05, Jonathan Wakely wrote:
On Mon, 9 Mar 2026 at 11:04, Tomasz Kaminski <[email protected]> wrote:
I believe, this caused failure
21_strings/basic_string/requirements/dr438/constructor.c in C++20 mode::
In file included from
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/functions.h:39,
from
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/safe_sequence.h:34,
from
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/string:37,
from
/home/tkaminsk/src/gcc/libstdc++-v3/testsuite/21_strings/basic_string/requirements/dr438/constructor.cc:23:
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/helper_functions.h:
In instantiation of 'constexpr bool __gnu_debug::__valid_range(_InputIterator,
_InputIterator) [with _InputIterator = int]':
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/functions.h:65:
required from 'constexpr _InputIterator __gnu_debug::__check_valid_range(const
_InputIterator&, const _InputIterator&, const char*, unsigned int, const char*)
[with _InputIterator = int]'
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/string:238: required
from '__gnu_debug::basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator,
_InputIterator, const _Allocator&) [with _InputIterator = int; _CharT = char; _Traits =
std::char_traits<char>; _Allocator = std::allocator<char>]'
/home/tkaminsk/src/gcc/libstdc++-v3/testsuite/21_strings/basic_string/requirements/dr438/constructor.cc:28:
required from here
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/helper_functions.h:212:
error: no matching function for call to '__iterator_category(int&)'
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/helper_functions.h:212:
note: there is 1 candidate
In file included from
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_construct.h:61,
from
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:59,
from
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/string:45,
from
/home/tkaminsk/src/gcc/libstdc++-v3/testsuite/21_strings/basic_string/requirements/dr438/constructor.cc:22:
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterator_base_types.h:241:
note: candidate 1: 'template<class _Iter> constexpr typename
std::iterator_traits<_Iterator>::iterator_category std::__iterator_category(const
_Iter&)'
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterator_base_types.h:241:
note: template argument deduction/substitution failed:
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterator_base_types.h:
In substitution of 'template<class _Iter> constexpr typename
std::iterator_traits<_Iterator>::iterator_category std::__iterator_category(const
_Iter&) [with _Iter = int]':
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/helper_functions.h:212:
required from 'constexpr bool __gnu_debug::__valid_range(_InputIterator,
_InputIterator) [with _InputIterator = int]'
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/functions.h:65:
required from 'constexpr _InputIterator __gnu_debug::__check_valid_range(const
_InputIterator&, const _InputIterator&, const char*, unsigned int, const char*)
[with _InputIterator = int]'
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/string:238: required
from '__gnu_debug::basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator,
_InputIterator, const _Allocator&) [with _InputIterator = int; _CharT = char; _Traits =
std::char_traits<char>; _Allocator = std::allocator<char>]'
/home/tkaminsk/src/gcc/libstdc++-v3/testsuite/21_strings/basic_string/requirements/dr438/constructor.cc:28:
required from here
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterator_base_types.h:241:
error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
compiler exited with status 1
FAIL: 21_strings/basic_string/requirements/dr438/constructor.cc -std=gnu++20
(test for excess errors)
Excess errors:
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/helper_functions.h:212:
error: no matching function for call to '__iterator_category(int&)'
/home/tkaminsk/build/gcc/16/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_iterator_base_types.h:241:
error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
This looks like *exactly* the error that the workaround was protecting
against. So it's not so useless.
On Mon, Mar 2, 2026 at 7:00 AM François Dumont <[email protected]> wrote:
Hi
libstdc++: [_GLIBCXX_DEBUG][__cplusplus >= 201103L] Remove useless
workaround
Starting with C++11 we leverage on template parameter requirement
to prevent
instantiation of methods taking iterators with invalid types.
So the _GLIBCXX_DEBUG mode do not need to check for potential
ambiguity between
integer type and iterator type anymore.
libstdc++-v3/ChangeLog:
* include/debug/functions.h
[__cplusplus >= 201103L](__foreign_iterator_aux): Remove.
[__cplusplus >= 201103L](__foreign_iterator): Adapt to use
__foreign_iterator_aux2.
* include/debug/helper_functions.h
[__cplusplus >= 201103L]: Remove include
bits/cpp_type_traits.h.
[__cplusplus >= 201103L](_Distance_traits<_Integral,
std::__true_type>): Remove.
[__cplusplus >= 201103L](__valid_range_aux(_Integral,
_Integral, std::__true_type)):
Remove.
[__cplusplus >= 201103L](__valid_range_aux(_Iterator,
_Iterator, std::__false_type)):
Remove.
[__cplusplus >= 201103L]
(__valid_range_aux(_Integral, _Integral,
_Distance_traits<_Integral>::__type&,
std::__true_type)): Remove.
[__cplusplus >= 201103L]
(__valid_range_aux(_Iterator, _Iterator,
_Distance_traits<_Iterator>::__type&,
std::__false_type)): Remove.
[__cplusplus >= 201103L](__valid_range(_Iterator,
_Iterator)): Adapt.
[__cplusplus >= 201103L]
(__valid_range(_Iterator, _Iterator,
_Distance_traits<_Iterator>::__type&)): Adapt.
Tested under Linux x64 _GLIBCXX_DEBUG mode.
Ok to commit ?
François
diff --git a/libstdc++-v3/include/debug/string
b/libstdc++-v3/include/debug/string
index d5ee1d9e193..556e1d63939 100644
--- a/libstdc++-v3/include/debug/string
+++ b/libstdc++-v3/include/debug/string
@@ -231,7 +231,12 @@ namespace __gnu_debug
const _Allocator& __a = _Allocator())
: _Base(__n, __c, __a) { }
+#if __cplusplus >= 201103L
+ template<typename _InputIterator,
+ typename = std::_RequireInputIter<_InputIterator>>
+#else
template<typename _InputIterator>
+#endif
basic_string(_InputIterator __begin, _InputIterator __end,
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base(