From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 4/4] Remove operator== and operator!= from gdb::span
Date: Tue, 03 Nov 2026 12:18:43 -0700 [thread overview]
Message-ID: <20261103-span-part-1-v1-4-133180dd43a5@adacore.com> (raw)
In-Reply-To: <20261103-span-part-1-v1-0-133180dd43a5@adacore.com>
gdb::span currently provides operator== and operator!=. However,
these aren't part of the C++20 std::span. There, instead, one must
use std::ranges::equal for deep equality.
This patch changes gdb::span to be similar, introducing
gdb::ranges::equal.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31422
---
gdb/dwarf2/read-debug-names.c | 9 ++++++---
gdb/value.c | 2 +-
gdbsupport/span.h | 14 +++++---------
3 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index a1e9d8c12ee..ca3b46fc9b1 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -817,17 +817,20 @@ read_debug_names_from_section (dwarf2_per_objfile *per_objfile,
aug_repr.c_str ());
}
- if (augmentation_string == gdb::make_span (dwarf5_augmentation_1))
+ if (gdb::ranges::equal (augmentation_string,
+ gdb::make_span (dwarf5_augmentation_1)))
{
warning (_(".debug_names created by an old version of gdb; ignoring"));
return false;
}
- else if (augmentation_string == gdb::make_span (dwarf5_augmentation_2))
+ else if (gdb::ranges::equal (augmentation_string,
+ gdb::make_span (dwarf5_augmentation_2)))
{
map.augmentation_is_gdb = true;
map.gdb_augmentation_version = 2;
}
- else if (augmentation_string == gdb::make_span (dwarf5_augmentation_3))
+ else if (gdb::ranges::equal (augmentation_string,
+ gdb::make_span (dwarf5_augmentation_3)))
{
map.augmentation_is_gdb = true;
map.gdb_augmentation_version = 3;
diff --git a/gdb/value.c b/gdb/value.c
index 36e81eb9139..f0e1905b9a7 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -4387,7 +4387,7 @@ static bool
check_ranges_vector (gdb::span<const range> ranges,
gdb::span<const range> expected)
{
- return ranges == expected;
+ return gdb::ranges::equal (ranges, expected);
}
/* Test the insert_into_bit_range_vector function. */
diff --git a/gdbsupport/span.h b/gdbsupport/span.h
index 01429bcc666..360ff766182 100644
--- a/gdbsupport/span.h
+++ b/gdbsupport/span.h
@@ -229,9 +229,12 @@ void copy (gdb::span<U> src, gdb::span<T> dest)
RHS have the same sizes, and whether each pair of elements of LHS
and RHS at the same position compares equal. */
+namespace ranges
+{
+
template <typename T>
bool
-operator== (const gdb::span<T> &lhs, const gdb::span<T> &rhs)
+equal (const gdb::span<T> &lhs, const gdb::span<T> &rhs)
{
if (lhs.size () != rhs.size ())
return false;
@@ -243,14 +246,7 @@ operator== (const gdb::span<T> &lhs, const gdb::span<T> &rhs)
return true;
}
-/* Compare two spans for inequality. */
-
-template <typename T>
-bool
-operator!= (const gdb::span<T> &lhs, const gdb::span<T> &rhs)
-{
- return !(lhs == rhs);
-}
+} /* namespace ranges */
/* Create a span from a pointer to an array and an element
count.
--
2.56.0
next prev parent reply other threads:[~2026-11-03 19:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 19:18 [PATCH 0/4] Rename gdb::array_view to gdb::span Tom Tromey
2026-11-03 19:18 ` [PATCH 1/4] Rename array_view files Tom Tromey
2026-11-10 20:07 ` Simon Marchi
2026-11-10 20:34 ` Tom Tromey
2026-11-10 20:37 ` Simon Marchi
2026-11-03 19:18 ` [PATCH 2/4] Rename gdb::array_view to gdb::span Tom Tromey
2026-11-03 19:18 ` [PATCH 3/4] Rename gdb::make_array_view to gdb::make_span Tom Tromey
2026-11-03 19:18 ` Tom Tromey [this message]
2026-11-10 20:03 ` [PATCH 4/4] Remove operator== and operator!= from gdb::span Simon Marchi
2026-11-10 20:28 ` Simon Marchi
2026-11-11 15:29 ` Tom Tromey
2026-11-11 15:46 ` Simon Marchi
2026-11-11 16:24 ` Tom Tromey
2026-11-11 16:30 ` Simon Marchi
2026-11-11 17:18 ` Tom Tromey
2026-11-11 17:19 ` Tom Tromey
2026-11-04 14:22 ` [PATCH 0/4] Rename gdb::array_view to gdb::span Tom Tromey
2026-11-10 20:29 ` Simon Marchi
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=20261103-span-part-1-v1-4-133180dd43a5@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.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