public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Avoid allocator operator== in _Safe_container
Date: Mon, 9 Aug 2021 11:45:52 +0100	[thread overview]
Message-ID: <CACb0b4m1kGHhXY1M98Z5UCxfRT0udY6X82Q2h7ysXN+cdV5Xxg@mail.gmail.com> (raw)
In-Reply-To: <CACb0b4kmH_Mec7jW_iFe7nbcbhnFiHiQts=LXyby2P1ULaL5Sg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 735 bytes --]

On Mon, 9 Aug 2021 at 11:34, Jonathan Wakely wrote:
>
> On Mon, 9 Aug 2021 at 11:33, Jonathan Wakely wrote:
> >
> > On Mon, 9 Aug 2021 at 11:26, François Dumont via Libstdc++
> > <libstdc++@gcc.gnu.org> wrote:
> > >
> > > Some newly introduced tests in
> > > 23_containers/unordered_map/cons/default.cc revealed that we are forcing
> > > the allocator type to have a operator==.
> >
> > All allocators are required to have operator== so that should not be a
> > problem. What is the error?
>
> OK, I see it. I just forgot to define operator== and operator!= for
> the custom allocator in that new test, and that should be added.

Fixed like this instead. Tested x86_64-linux with -D_GLIBCXX_DEBUG.
Pushed to trunk.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1827 bytes --]

commit 2eff2a3cb521c58212885a3dca638764285b5691
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Aug 9 11:36:07 2021

    libstdc++: Make allocator equality comparable in tests
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/23_containers/unordered_map/cons/default.cc: Add
            equality comparison operators to allocator.
            * testsuite/23_containers/unordered_set/cons/default.cc:
            Likewise.

diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/cons/default.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/cons/default.cc
index d64d078a7da..7a785e980b1 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_map/cons/default.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/cons/default.cc
@@ -18,6 +18,9 @@ template<typename T>
 
     void deallocate(T *p, std::size_t n)
     { std::allocator<T>().deallocate(p, n); }
+
+    bool operator==(const NoDefaultConsAlloc&) const { return true; }
+    bool operator!=(const NoDefaultConsAlloc&) const { return false; }
   };
 
 using Map = std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/cons/default.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/default.cc
index 41281d3d774..fb87c96ce9d 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/cons/default.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/default.cc
@@ -18,6 +18,9 @@ template<typename T>
 
     void deallocate(T *p, std::size_t n)
     { std::allocator<T>().deallocate(p, n); }
+
+    bool operator==(const NoDefaultConsAlloc&) const { return true; }
+    bool operator!=(const NoDefaultConsAlloc&) const { return false; }
   };
 
 using Set = std::unordered_set<int, std::hash<int>, std::equal_to<int>,

  reply	other threads:[~2021-08-09 10:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 10:23 François Dumont
2021-08-09 10:33 ` Jonathan Wakely
2021-08-09 10:34   ` Jonathan Wakely
2021-08-09 10:45     ` Jonathan Wakely [this message]
2021-08-09 11:52       ` François Dumont
2021-08-09 12:08         ` François Dumont
2021-08-09 14:24           ` 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=CACb0b4m1kGHhXY1M98Z5UCxfRT0udY6X82Q2h7ysXN+cdV5Xxg@mail.gmail.com \
    --to=jwakely@redhat.com \
    --cc=frs.dumont@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).