On Thu, 1 Oct 2026 at 18:36, Jonathan Wakely <[email protected]> wrote:
>
> On Thu, 1 Oct 2026 at 18:29, François Dumont <[email protected]> wrote:
> >
> > I'd like to commit this code cleanup. It is not fixing anything except
> > perhaps for some code analysis tools reporting minor issues.
>
> Does this really clean things up? Now there are two definitions for
> most of those constructors.
>
> Maybe it's possible to just use the >= 201103 versions
> unconditionally, and disable -Wc++11-extensions warnings?
Yes, both GCC and Clang compile this without warnings using -std=c++98
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc++11-extensions"
template<class T>
struct S
{
S() = default;
S(const S&) = default;
T i = 0;
};
#pragma GCC diagnostic pop
int main()
{
S<int> s;
}
So you can add those pragmas and then *really* clean up the code, by
only keeping the versions with the defaulted constructors and the
default member-initializers.
>
>
> >
> > Despite being trivial and limited to _GLIBCCX_DEBUG I'd like to have
> > some feedback at least on the ChangeLog, to make sure I've used the
> > right C++ words.
> >
> > libstdc++: [_GLIBCXX_DEBUG] _Safe_iterator_base/_Safe_sequence_base
> > code cleanup
> >
> > Use inlined initialization for both _Safe_iterator_base and
> > _Safe_sequence_base and so default their default constructor.
> >
> > Have _Safe_sequence_base copy constructor always defined, using same
> > implementation as the default constructor.
> >
> > Use value-initialization syntax when setting pointers to nullptr
> > before C++11
> > instead of using 0.
> >
> > libstdc++-v3/ChangeLog:
> >
> > * include/debug/safe_base.h
> > [__cplusplus >= 201103L]
> > (_Safe_iterator_base::_M_sequence): Add inline initialization.
>
> You've added a default member-initializer
>
> > (_Safe_iterator_base::_M_version): Likewise.
> > (_Safe_iterator_base::_M_prior): Likewise.
> > (_Safe_iterator_base::_M_next): Likewise.
> > [__cplusplus < 201103L](_Safe_iterator_base()): Value
> > initialize members.
> > [__cplusplus >= 201103L](_Safe_iterator_base()): Default
> > implementation.
> > (_Safe_iterator_base(const _Safe_sequence_base*, bool)):
> > Value initialize members.
> > (_Safe_iterator_base(const _Safe_iterator_base&, bool)):
> > Likewise.
> > [__cplusplus >= 201103L]
> > (_Safe_sequence_base::_M_iterators): Add inline initialization.
> > (_Safe_sequence_base::_M_const_iterators): Likewise.
> > (_Safe_sequence_base::_M_version): Likewise.
> > [__cplusplus < 201103L](_Safe_sequence_base()): Value
> > initialize members.
> > [__cplusplus >= 201103L](_Safe_sequence_base()): Default
> > implementation.
> > [__cplusplus < 201103L](_Safe_sequence_base(const
> > _Safe_sequence_base&)): New.
> >
> > Tested under Linux x86_64 C++98 and C++20 _GLIBCXX_DEBUG mode.
> >
> > Ok to commit ?
> >
> > François
> >