[PATCH][_GLIBCXX_DEBUG][__cplusplus >= 201103L] Remove useless workaround
Jonathan Wakely
jwakely.gcc@gmail.com
Mon Mar 9 11:05:55 GMT 2026
On Mon, 9 Mar 2026 at 11:04, Tomasz Kaminski <tkaminsk@redhat.com> 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 <frs.dumont@gmail.com> 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
>>
More information about the Libstdc++
mailing list