From: Simon Marchi <simon.marchi@efficios.com>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gdb/unittests: skip mixed constness span tests with libstdc++ debug mode
Date: Mon, 23 Nov 2026 10:12:04 -0500 [thread overview]
Message-ID: <65e18f2f-bbde-47cb-81e7-583e0139decc@efficios.com> (raw)
In-Reply-To: <xhuyfy0amdiyf.fsf@aburgess-thinkpadp1gen8.rmtgb.csb>
On 11/21/26 3:32 PM, Andrew Burgess wrote:
> 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.
If we encountered this is real code, I suppose we could add a cast to
make sure both sides have the exact same type (if possible), and add a
comment that it is a workaround for _GLIBCXX_DEBUG.
In the case of the test, it wouldn't have made sense to add a cast,
because we precisely want to test mixed constness. On the other hand, I
am not sure what point there is to test that, if we can't use that
feature in real code due to this _GLIBCXX_DEBUG bug. Anyway, I am in
the mindset that gdb::array_view is going to be deleted soon-ish, so I
would not spend too much time thinking about that.
Simon
prev parent reply other threads:[~2026-11-23 15:12 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
2026-11-23 15:12 ` Simon Marchi [this message]
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=65e18f2f-bbde-47cb-81e7-583e0139decc@efficios.com \
--to=simon.marchi@efficios.com \
--cc=aburgess@redhat.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