On Fri, 23 May 2025 at 18:56, Paul Keir <paul.k...@uws.ac.uk> wrote:
>
> This patch implements C++26 "Enabling the Use of weak_ptr as Keys in 
> Unordered Associative Containers", as specified in P1901R2.

Splendid, thanks. I'll review this more carefully next week.

Some quick comments:

This should define the __cpp_lib_smart_pointer_owner_equality feature
test macro.

To do that you need to add a new entry in include/bits/version.def
(see the comments at the top and the existing entries which should be
fairly clear - I am in the middle of documenting this process).
Then in the $objdir/x86_64-pc-linux-gnu/libstdc++-v3/include directory
run 'make update-version' which should regenerate the bits/version.h
file to include your new macro.
Then in <memory> define __glibcxx_want_smart_pointer_owner_equality
before including <bits/version.h>.

> diff --git a/libstdc++-v3/testsuite/20_util/owner_equal/cmp.cc 
> b/libstdc++-v3/testsuite/20_util/owner_equal/cmp.cc
> new file mode 100644
> index 00000000000..c958d9c62ea
> --- /dev/null
> +++ b/libstdc++-v3/testsuite/20_util/owner_equal/cmp.cc
> @@ -0,0 +1,122 @@
> +// { dg-do run { target c++26 } }
> +// { dg-require-effective-target hosted }
> +
> +// Copyright (C) 2008-2025 Free Software Foundation, Inc.

I see that all the new tests have copyright dates varying from 2008 to
2017, but they're all new files (I don't think they copy anythign from
existing tests, right?). So they should not have copyright dates
claiming to be written in the past. They also shouldn't have copyright
notices claiming to be owned by the FSF if you're contributing them
under the DCO terms, because you retain your own copyright.

My preference for new tests is not to bother with the copyright notice
or license text at all. Nothing in those tests looks very novel or
inventive, it's just repetitive, fairly mechanical testing of the API.
I am sceptical whether such things are even copyrightable. So I don't
both with the 20 lines of comments in each file, e.g. see
testsuite/20_util/weak_ptr/atomic_weak_ptr.cc from 2022.


> +// This file is part of the GNU ISO C++ Library.  This library is free
> +// software; you can redistribute it and/or modify it under the
> +// terms of the GNU General Public License as published by the
> +// Free Software Foundation; either version 3, or (at your option)
> +// any later version.
> +
> +// This library is distributed in the hope that it will be useful,
> +// but WITHOUT ANY WARRANTY; without even the implied warranty of
> +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +// GNU General Public License for more details.
> +
> +// You should have received a copy of the GNU General Public License along
> +// with this library; see the file COPYING3.  If not see
> +// <http://www.gnu.org/licenses/>.
> +
> +// 20.3.2.6 Struct owner_equal [util.smartptr.owner.equal]

Please put the C++ standard version, or in this case working draft
number, in these comments, e.g.
// N5008 20.3.2.6 Struct owner_equal [util.smartptr.owner.equal]

We didn't used to do that (as you'll see in the old tests) and it
becomes pretty pointless to just have a subclause number in some
unspecified document (unlike the C standard, the C++ subclause numbers
change dramatically between standards).

I have been trying to add "C++11" or "C++03" those comments in old
tests when I touch the file for some other reason.

Reply via email to