From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SZB9HHGqAGs3HiUAWB0awg (envelope-from ) for ; Fri, 20 Nov 2026 15:15:45 -0500 Received: by simark.ca (Postfix, from userid 112) id 553A41E0CA; Fri, 20 Nov 2026 15:15:45 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1F6531E023 for ; Fri, 20 Nov 2026 15:15:44 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C107340A1FA1 for ; Fri, 20 Nov 2026 20:15:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C107340A1FA1 Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 5476C40A24AA for ; Fri, 20 Nov 2026 20:15:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5476C40A24AA Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5476C40A24AA Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795205718; cv=none; b=xYoLeiKOG8B9P0kXFl15RiLNq9jYACCzSn890dLsW6fKoeSCAdM2V5fEAFGyBithDtSgIJs2jf+Y64xmqG6xqzLnJFWTEZVGsHba3+EdARvpYPSyXAvq4ZvZuipRMC48vTJfM34NlBG8fvXLV4MsST4LxTJe0FuHQnG7lLh7h20= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795205718; c=relaxed/simple; bh=573Wn5gBOHTtJbePOzHfq0pLANXinbssEieQe5uYAj8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=YY1ZeqaDa4K/C2Rpyt84FE17+0+KlGz1e90vCOesgc+SK8ehsY0REg78yoGBNlTGNthf2Si2xkFJIIlPLNo8dQpXtHFyqf+nXrwsVNHvy0gXGIcTnCV4LhcvTc/8g7w1jYar7HsToNpDRai7oAQZ59/zWelgxXL09AG5vC/SZi4= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5476C40A24AA Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 6AKKFBHM203029 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Nov 2026 15:15:16 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 6AKKFBHM203029 Received: by simark.ca (Postfix) id 77A251E023; Fri, 20 Nov 2026 15:15:11 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] gdb/unittests: skip mixed constness span tests with libstdc++ debug mode Date: Fri, 20 Nov 2026 15:15:01 -0500 Message-ID: <20261120201510.3162938-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.56.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 20 Nov 2026 20:15:11 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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 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. Change-Id: I54ff18ecc2463183ff9a0617a6e06662c1b092c5 --- gdb/unittests/span-selftests.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gdb/unittests/span-selftests.c b/gdb/unittests/span-selftests.c index 2317f34d1d63..c29b63a03c27 100644 --- a/gdb/unittests/span-selftests.c +++ b/gdb/unittests/span-selftests.c @@ -314,18 +314,21 @@ check_ptr_ptr_ctor () SELF_CHECK (view.data () == &data[1]); SELF_CHECK (view[0] == data[1]); SELF_CHECK (view[1] == data[2]); - - gdb_byte array[] = {0x11, 0x22, 0x33, 0x44}; - const gdb_byte *p1 = array; - gdb_byte *p2 = array + ARRAY_SIZE (array); - gdb::span view2 (p1, p2); } -/* Check construction with a pair of pointers of mixed constness. */ +/* Check construction with a pair of pointers of mixed constness. + + This is skipped when using libstdc++'s std::span in debug mode, + because of this libstdc++ bug requiring the two arguments to have + the exact same type: + + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100990#c1 + */ static void check_ptr_ptr_mixed_cv () { +#if !defined (_GLIBCXX_DEBUG) || __cplusplus < 202002L gdb_byte array[] = {0x11, 0x22, 0x33, 0x44}; const gdb_byte *cp = array; gdb_byte *p = array; @@ -333,6 +336,12 @@ check_ptr_ptr_mixed_cv () gdb::span view2 (p, cp); SELF_CHECK (view1.empty ()); SELF_CHECK (view2.empty ()); + + const gdb_byte *p1 = array; + gdb_byte *p2 = array + ARRAY_SIZE (array); + gdb::span view3 (p1, p2); + SELF_CHECK (view3.size () == ARRAY_SIZE (array)); +#endif } /* Check range-for support (i.e., begin()/end()). This is a template base-commit: f50db130cf4ef292211cdd81a950c8e6469aa476 -- 2.56.1