From: Andrew Burgess <aburgess@redhat.com>
To: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH 1/2] gdb/unittests: skip mixed constness span tests with libstdc++ debug mode
Date: Sat, 21 Nov 2026 20:32:08 +0000 [thread overview]
Message-ID: <xhuyfy0amdiyf.fsf@aburgess-thinkpadp1gen8.rmtgb.csb> (raw)
In-Reply-To: <20261120201510.3162938-1-simon.marchi@efficios.com>
Simon Marchi <simon.marchi@efficios.com> writes:
> When building GDB in C++20 mode with -D_GLIBCXX_DEBUG, span-selftests.c
> fails to compile with:
>
> /usr/include/c++/16/span:196:11: error: no matching function for call to '__valid_range(const unsigned char*&, unsigned char*&)'
>
> In debug mode, the (first, last) constructor of libstdc++'s std::span
> validates the range by calling __gnu_debug::__valid_range, which
> requires both iterators to have the same type. Constructing a span from
> two pointers of different constness is valid C++20, but doesn't compile
> in that configuration. I believe this is an instance of this existing
> gcc bug:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100990<F12>
>
> As a workaround, move the mixed constness case at the end of
> check_ptr_ptr_ctor to check_ptr_ptr_mixed_cv, and skip the body of
> check_ptr_ptr_mixed_cv when building in C++20 mode with _GLIBCXX_DEBUG
> defined.
I also ran into this, and was thinking about how to fix this. What you
propose is fine because these are unittests, and skipping them doesn't
really break any GDB functionality. But what happens when we want to
use this in actual GDB code? I guess we'll need to add casts at the
point of use?
But then, what's the alternative, avoid std::span for now? Though I'd
be fine with that, I suspect others might disagree.
Guess I'm not here to add anything constructive, just noting that this
patch is just hiding the issue until it bites someone later on.
Thanks,
Andrew
next prev parent reply other threads:[~2026-11-21 20:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 20:15 Simon Marchi
2026-11-20 20:15 ` [PATCH 2/2] gdb: fix out-of-bounds span in append_composite_type_field_raw Simon Marchi
2026-11-20 21:22 ` Tom Tromey
2026-11-21 5:09 ` Simon Marchi
2026-11-20 21:22 ` [PATCH 1/2] gdb/unittests: skip mixed constness span tests with libstdc++ debug mode Tom Tromey
2026-11-21 20:32 ` Andrew Burgess [this message]
2026-11-23 15:12 ` 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=xhuyfy0amdiyf.fsf@aburgess-thinkpadp1gen8.rmtgb.csb \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
/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