From: Jonathan Wakely <jwakely@redhat.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: Jonathan Wakely <jwakely.gcc@gmail.com>,
libstdc++ <libstdc++@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Hashtable PR96088
Date: Wed, 2 Jun 2021 13:35:33 +0100 [thread overview]
Message-ID: <YLd7FdK7XHmxENuw@redhat.com> (raw)
In-Reply-To: <YLZ4H2E5XoMJXMI+@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1768 bytes --]
On 01/06/21 19:10 +0100, Jonathan Wakely wrote:
>On 01/06/21 18:47 +0100, Jonathan Wakely wrote:
>>On 01/06/21 18:45 +0100, Jonathan Wakely wrote:
>>>On 22/05/21 18:35 +0200, François Dumont wrote:
>>>>diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc
>>>>new file mode 100644
>>>>index 00000000000..53bb754dab6
>>>>--- /dev/null
>>>>+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc
>>>>@@ -0,0 +1,271 @@
>>>>+// { dg-do run { target c++11 } }
>>>>+
>>>>+// Copyright (C) 2021 Free Software Foundation, Inc.
>>>>+//
>>>>+// 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/>.
>>>>+
>>>>+// libstdc++/96088
>>>>+
>>>>+#include <string_view>
>>>
>>>This is a c++11 test, but it uses <string_view>.
>>>
>>>The test fails for make check RUNTESTFLAGS=--target_board=unix/-std=gnu++11
>>>
>>>I assume it should use { target c++17 } instead?
>>
>>Same for 23_containers/unordered_map/96088.cc
>
>I've pushed this fix.
And this one too.
Tested x86_64-linux.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 4658 bytes --]
commit 81eab204a56dcd8acb1ca5d7df277437ca07b51a
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jun 2 12:33:38 2021
libstdc++: Fix tests for COW std::string [PR 96088]
The expected number of allocations is different when copying COW
strings.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/96088
* testsuite/23_containers/unordered_map/96088.cc: Adjust
expected number of allocations.
* testsuite/23_containers/unordered_set/96088.cc: Likewise.
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc
index e552b04f8c8..83ca1c0afd6 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc
@@ -222,7 +222,8 @@ test03()
std::vector<std::pair<std::string, int>> v;
v.insert(v.end(), lst.begin(), lst.end());
- auto __offset = __gnu_test::counter::count();
+ const auto origin = __gnu_test::counter::count();
+
{
__gnu_test::counter::reset();
std::unordered_map<std::string, int,
@@ -231,15 +232,19 @@ test03()
um.insert(v.begin(), v.end());
VERIFY( um.size() == 1 );
- VERIFY( __gnu_test::counter::count() - __offset == 3 );
- VERIFY( __gnu_test::counter::get()._M_increments == 3 );
+ // Allocate array of buckets, a node, and the std::string (unless COW).
+ constexpr std::size_t increments = _GLIBCXX_USE_CXX11_ABI ? 3 : 2;
+
+ VERIFY( __gnu_test::counter::count() == origin + increments );
+ VERIFY( __gnu_test::counter::get()._M_increments == increments );
um.insert(v.begin(), v.end());
VERIFY( um.size() == 1 );
- VERIFY( __gnu_test::counter::count() - __offset == 3 );
- VERIFY( __gnu_test::counter::get()._M_increments == 3 );
+ VERIFY( __gnu_test::counter::count() == origin + increments );
+ VERIFY( __gnu_test::counter::get()._M_increments == increments );
}
+ VERIFY( __gnu_test::counter::count() == origin );
{
__gnu_test::counter::reset();
@@ -250,8 +255,11 @@ test03()
std::make_move_iterator(v.end()));
VERIFY( um.size() == 1 );
- VERIFY( __gnu_test::counter::count() - __offset == 2 );
- VERIFY( __gnu_test::counter::get()._M_increments == 2 );
+ // Allocate array of buckets and a node. String is moved.
+ constexpr std::size_t increments = 2;
+
+ VERIFY( __gnu_test::counter::count() == origin + increments );
+ VERIFY( __gnu_test::counter::get()._M_increments == increments );
}
}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc
index efb2f9eb6b1..83d5475c677 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc
@@ -223,7 +223,8 @@ test03()
std::vector<std::string> v;
v.insert(v.end(), lst.begin(), lst.end());
- auto __offset = __gnu_test::counter::count();
+ const auto origin = __gnu_test::counter::count();
+
{
__gnu_test::counter::reset();
std::unordered_set<std::string,
@@ -232,15 +233,19 @@ test03()
us.insert(v.begin(), v.end());
VERIFY( us.size() == 1 );
- VERIFY( __gnu_test::counter::count() - __offset == 3 );
- VERIFY( __gnu_test::counter::get()._M_increments == 3 );
+ // Allocate array of buckets, a node, and the std::string (unless COW).
+ constexpr std::size_t increments = _GLIBCXX_USE_CXX11_ABI ? 3 : 2;
+
+ VERIFY( __gnu_test::counter::count() == origin + increments );
+ VERIFY( __gnu_test::counter::get()._M_increments == increments );
us.insert(v.begin(), v.end());
VERIFY( us.size() == 1 );
- VERIFY( __gnu_test::counter::count() - __offset == 3 );
- VERIFY( __gnu_test::counter::get()._M_increments == 3 );
+ VERIFY( __gnu_test::counter::count() == origin + increments );
+ VERIFY( __gnu_test::counter::get()._M_increments == increments );
}
+ VERIFY( __gnu_test::counter::count() == origin );
{
__gnu_test::counter::reset();
@@ -251,8 +256,11 @@ test03()
std::make_move_iterator(v.end()));
VERIFY( us.size() == 1 );
- VERIFY( __gnu_test::counter::count() - __offset == 2 );
- VERIFY( __gnu_test::counter::get()._M_increments == 2 );
+ // Allocate array of buckets and a node. String is moved.
+ constexpr std::size_t increments = 2;
+
+ VERIFY( __gnu_test::counter::count() == origin + increments );
+ VERIFY( __gnu_test::counter::get()._M_increments == increments );
}
}
next prev parent reply other threads:[~2021-06-02 12:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 12:36 Hashtable PR96088 Work in Progress François Dumont
2020-10-17 16:21 ` [PATCH] Hashtable PR96088 François Dumont
2020-10-24 14:25 ` François Dumont
2020-12-04 9:10 ` François Dumont
2021-05-06 20:03 ` François Dumont
2021-05-17 19:24 ` François Dumont
2021-05-20 16:44 ` Jonathan Wakely
2021-05-21 5:55 ` François Dumont
2021-05-21 6:48 ` Jonathan Wakely
2021-05-21 6:55 ` Jonathan Wakely
2021-05-22 16:35 ` François Dumont
2021-05-24 11:19 ` Jonathan Wakely
2021-06-01 17:45 ` Jonathan Wakely
2021-06-01 17:47 ` Jonathan Wakely
2021-06-01 18:10 ` Jonathan Wakely
2021-06-01 20:00 ` François Dumont
2021-06-02 12:35 ` Jonathan Wakely [this message]
2021-05-24 9:31 ` François Dumont
2021-05-24 11:18 ` Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YLd7FdK7XHmxENuw@redhat.com \
--to=jwakely@redhat.com \
--cc=frs.dumont@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely.gcc@gmail.com \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).