public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Fix tests that use invalid types in ordered containers
Date: Tue, 28 Sep 2021 20:25:38 +0100	[thread overview]
Message-ID: <YVNsMjwtW9bnTFEd@redhat.com> (raw)

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

Types used in ordered containers need to be comparable, or the container
needs to use a custom comparison function. These tests fail when
_GLIBCXX_CONCEPT_CHECKS is defined, because the element types aren't
comparable.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/20_util/is_nothrow_swappable/value.h: Use custom
	comparison function for priority_queue of type with no
	relational operators.
	* testsuite/20_util/is_swappable/value.h: Likewise.
	* testsuite/24_iterators/output/concept.cc: Add operator< to
	type used in set.

Tested x86_64-linux. Committed to trunk.


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

commit 4000d722e609bbbb1e923721b54911bb784eeec3
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Sep 24 13:21:34 2021

    libstdc++: Fix tests that use invalid types in ordered containers
    
    Types used in ordered containers need to be comparable, or the container
    needs to use a custom comparison function. These tests fail when
    _GLIBCXX_CONCEPT_CHECKS is defined, because the element types aren't
    comparable.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/20_util/is_nothrow_swappable/value.h: Use custom
            comparison function for priority_queue of type with no
            relational operators.
            * testsuite/20_util/is_swappable/value.h: Likewise.
            * testsuite/24_iterators/output/concept.cc: Add operator< to
            type used in set.

diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.h b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.h
index 62b3db8dc1f..d6f166bee46 100644
--- a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.h
+++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.h
@@ -285,7 +285,9 @@ void test01()
   static_assert(test_property<is_nothrow_swappable,
 		std::queue<ThrowCopyConsClass>>(true), "");
   static_assert(test_property<is_nothrow_swappable,
-		std::priority_queue<ThrowCopyConsClass>>(true), "");
+		std::priority_queue<ThrowCopyConsClass,
+				    std::vector<ThrowCopyConsClass>,
+				    comps::CompareNoThrowCopyable>>(true), "");
   static_assert(test_property<is_nothrow_swappable,
 		std::stack<ThrowCopyConsClass>>(true), "");
   static_assert(test_property<is_nothrow_swappable,
diff --git a/libstdc++-v3/testsuite/20_util/is_swappable/value.h b/libstdc++-v3/testsuite/20_util/is_swappable/value.h
index 2f7a00b9aef..eb3f96dc0b1 100644
--- a/libstdc++-v3/testsuite/20_util/is_swappable/value.h
+++ b/libstdc++-v3/testsuite/20_util/is_swappable/value.h
@@ -55,6 +55,13 @@ namespace funny {
   {
     friend void swap(F3&, F3) {}
   };
+
+  struct DummyCmp
+  {
+    template<class T>
+      bool operator()(const T&, const T&) const
+      { return false; }
+  };
 }
 void test01()
 {
@@ -152,7 +159,9 @@ void test01()
   static_assert(test_property<is_swappable,
 		std::priority_queue<int>[1][2][3]>(true), "");
   static_assert(test_property<is_swappable,
-		std::priority_queue<construct::Nontrivial>>(true), "");
+		std::priority_queue<construct::Nontrivial,
+				    std::vector<construct::Nontrivial>,
+				    funny::DummyCmp>>(true), "");
   static_assert(test_property<is_swappable,
 		std::stack<int>>(true), "");
   static_assert(test_property<is_swappable,
diff --git a/libstdc++-v3/testsuite/24_iterators/output/concept.cc b/libstdc++-v3/testsuite/24_iterators/output/concept.cc
index ddb646b22ad..a0524387dab 100644
--- a/libstdc++-v3/testsuite/24_iterators/output/concept.cc
+++ b/libstdc++-v3/testsuite/24_iterators/output/concept.cc
@@ -68,7 +68,7 @@ using std::string;
 using std::string_view;
 using std::vector;
 
-struct B { };
+struct B { bool operator<(const B&) const; };
 
 static_assert( output_iterator< array<int, 1>::iterator, int > );
 static_assert( output_iterator< array<B, 1>::iterator, B > );

                 reply	other threads:[~2021-09-28 19:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=YVNsMjwtW9bnTFEd@redhat.com \
    --to=jwakely@redhat.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).