On Fri, 6 Mar 2026 at 09:01, Jakub Jelinek <[email protected]> wrote:
>
> On Thu, Mar 05, 2026 at 01:01:39PM -0500, Nathan Myers wrote:
> > --- a/libstdc++-v3/include/std/bitset
> > +++ b/libstdc++-v3/include/std/bitset
> > @@ -1290,11 +1290,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
> > _GLIBCXX23_CONSTEXPR
> > reference
> > operator[](size_t __position)
> > - { return reference(*this, __position); }
> > + {
> > + __glibcxx_assert(__position < _Nb);
> > + return reference(*this, __position);
> > + }
> >
> > _GLIBCXX_CONSTEXPR bool
> > operator[](size_t __position) const
> > - { return _Unchecked_test(__position); }
> > + {
> > + __glibcxx_assert(__position < _Nb);
> > + return _Unchecked_test(__position);
> > + }
> > ///@}
> >
> > /**
>
> This second change broke
> In file included from
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stdexcept_throw.h:34,
> from
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/bitset:49,
> from
> /home/jakub/src/gcc/gcc/testsuite/g++.old-deja/g++.martin/bitset1.C:3:
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/bitset: In
> member function 'constexpr bool std::bitset<_Nb>::operator[](std::size_t)
> const':
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/c++config.h:646:6:
> error: compound-statement in 'constexpr' function [-Wpedantic]
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/bitset:1301:9:
> note: in expansion of macro '__glibcxx_assert'
> compiler exited with status 1
> FAIL: g++.old-deja/g++.martin/bitset1.C -std=c++11 (test for excess errors)
> Excess errors:
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/c++config.h:646:6:
> error: compound-statement in 'constexpr' function [-Wpedantic]
>
> UNRESOLVED: g++.old-deja/g++.martin/bitset1.C -std=c++11 compilation failed
> to produce executable
> and
> In file included from
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:59,
> from
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/algorithm:62,
> from
> /home/jakub/src/gcc/gcc/testsuite/g++.old-deja/g++.other/headers1.C:9:
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/bitset: In
> member function 'constexpr bool std::bitset<_Nb>::operator[](std::size_t)
> const':
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/c++config.h:646:6:
> error: compound-statement in 'constexpr' function [-Wpedantic]
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/bitset:1301:9:
> note: in expansion of macro '__glibcxx_assert'
> compiler exited with status 1
> FAIL: g++.old-deja/g++.other/headers1.C -std=c++11 (test for excess errors)
> Excess errors:
> /home/jakub/src/gcc/obj16/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/c++config.h:646:6:
> error: compound-statement in 'constexpr' function [-Wpedantic]
>
> UNRESOLVED: g++.old-deja/g++.other/headers1.C -std=c++11 compilation failed
> to produce executable
>
> Perhaps the assert needs to be omitted for C++11 (C++98 is fine because the
> operator isn't constexpr in that case)?
Yeah we can live without the assertion for C++11. It's required for
C++26, and QoI for everything older.
Or we could just use a trap for C++11:
#if __cplusplus == 201103L
return _Unchecked_test(__position < _Nb ? __position :
(__builtin_trap(), __position));
#else
__glibcxx_assert(__position < _Nb);
return ...;
#endif