On Wed, 2 Feb 2022 at 00:23, Martin Sebor <mse...@gmail.com> wrote:
>
> On 2/1/22 17:15, Jonathan Wakely wrote:
> > On Wed, 2 Feb 2022 at 00:13, Martin Sebor <mse...@gmail.com> wrote:
> >>
> >> On 2/1/22 12:48, Jonathan Wakely wrote:
> >>> On Tue, 1 Feb 2022 at 18:54, Martin Sebor via Libstdc++
> >>> <libstd...@gcc.gnu.org> wrote:
> >>>>
> >>>> Passing an uninitialized object to a function that takes its argument
> >>>> by const reference is diagnosed by -Wmaybe-uninitialized because most
> >>>> such functions read the argument.  The exceptions are functions that
> >>>> don't access the object but instead use its address to compute
> >>>> a result.  This includes a number of std::array member functions such
> >>>> as std::array<N>::size() which returns the template argument N.  Such
> >>>> functions may be candidates for attribute const which also avoids
> >>>> the warning.  The attribute typically only benefits extern functions
> >>>> that IPA cannot infer the property from, but in this case it helps
> >>>> avoid the warning which runs very early on, even without optimization
> >>>> or inlining.  The attached patch adds the attribute to a subset of
> >>>> those member functions of std::array.  (It doesn't add it to const
> >>>> member functions like cbegin() or front() that return a const_iterator
> >>>> or const reference to the internal data.)
> >>>>
> >>>> It might be possible to infer this property from inline functions
> >>>> earlier on than during IPA and avoid having to annotate them explicitly.
> >>>> That seems like an enhancement worth considering in the future.
> >>>>
> >>>> Tested on x86_64-linux.
> >>>>
> >>>> Martin
> >>>
> >>> new file mode 100644
> >>> index 00000000000..b7743adf3c9
> >>> --- /dev/null
> >>> +++ b/libstdc++-v3/testsuite/23_containers/array/iterators/begin_end.cc
> >>> @@ -0,0 +1,56 @@
> >>> +// { dg-do compile { target c++11 } }
> >>> +//
> >>> +// Copyright (C) 2011-2022 Free Software Foundation, Inc.
> >>>
> >>> Those dates look wrong. I no longer bother putting a license text and
> >>> copyright notice on simple tests like this. It's meaningless to assert
> >>> copyright on something so trivial that doesn't do anything.
> >>>
> >>
> >> Should I take to mean that you're okay with the rest of the change
> >> (i.e., with the notice removed)?
> >
> > Yes, OK for trunk either with the notice entirely removed, or just fix
> > the dates (I don't think it is copied from an existing test dating
> > from 2011, right?)
>
> I copied it from 23_containers/array/iterators/end_is_one_past.cc
> without even looking at the dates.

Yeah, we all do that, and we all forget to fix the dates. It's just
one more reason not to bother putting 16 lines of licence notices in
tests, when the notice is often bigger than the test itself!

>
> >
> > Whichever you prefer.
> >
>
> Okay, pushed in r12-6992.

Thanks.

Reply via email to