On Wed, 7 Oct 2026 at 05:54, François Dumont <[email protected]> wrote:
>
> Committed, using '= 0' to initialize pointers.

Thanks!

>
> On 10/5/26 19:43, Jonathan Wakely wrote:
> > OK for trunk with a change to the commit log to mention it's using
> > C++11 extensions.
> >
> > On Mon, 5 Oct 2026 at 18:42, Jonathan Wakely <[email protected]> wrote:
> >> On Mon, 5 Oct 2026 at 18:34, François Dumont <[email protected]> wrote:
> >>> Much better indeed.
> >>>
> >>> Disabling C++11 extensions warning does not give access to 'nullptr'
> >>> keyword so I used value-initialization, I hope it is fine.
> >> We generally just use '= 0' to initialize pointers in C++98 code.
> >>
> >>> Maybe I should also use only 1 block of #pragma GCC diagnostic push/pop
> >>> so enclosing almost all header content within it ?
> >> If there were many uses of it then I'd say yes, but there are only two
> >> such blocks so this is OK.
> >>
> >>
> >>>       libstdc++: [_GLIBCXX_DEBUG] _Safe_iterator_base/_Safe_sequence_base
> >>> code cleanup
> >>>
> >>>       Use default member-initializer for both _Safe_iterator_base and
> >>>       _Safe_sequence_base and so default their default constructor.
> >>>
> >>>       Have _Safe_sequence_base copy constructor always defined,
> >>> forwarding to the default constructor.
> >>>
> >>>       Use value-initialization syntax when setting pointers to nullptr
> >>> instead of
> >>>       using '= 0'.
> >> The commit log should mention that it's using C++11 features but
> >> disabling the warnings with pragmas.
> >>
> >>
> >>>       libstdc++-v3/ChangeLog:
> >>>
> >>>               * include/debug/safe_base.h
> >>>               (_Safe_iterator_base::_M_sequence): Add default
> >>> member-initializer.
> >>>               (_Safe_iterator_base::_M_version): Likewise.
> >>>               (_Safe_iterator_base::_M_prior): Likewise.
> >>>               (_Safe_iterator_base::_M_next): Likewise.
> >>>               (_Safe_iterator_base()): Default implementation.
> >>>               (_Safe_iterator_base(const _Safe_sequence_base*, bool)):
> >>> Forward to default
> >>>               constructor.
> >>>               (_Safe_iterator_base(const _Safe_iterator_base&, bool)):
> >>> Likewise.
> >>>               (_Safe_sequence_base::_M_iterators): Add default
> >>> member-initializer.
> >>>               (_Safe_sequence_base::_M_const_iterators): Likewise.
> >>>               (_Safe_sequence_base::_M_version): Likewise.
> >>>               (_Safe_sequence_base()): Default implementation.
> >>>               (_Safe_sequence_base(const _Safe_sequence_base&)): Forward
> >>> to default
> >>>               constructor.
> >>>
> >>> Tested under Linux x86_64 _GLIBCXX_DEBUG mode C++98/C++20.
> >>>
> >>> Ok to commit ?
> >>>
> >>> François
> >>>
> >>> On 10/2/26 00:14, Jonathan Wakely wrote:
> >>>> 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
> >>>>>>
>

Reply via email to