From patchwork Tue Aug 16 18:54:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Patchwork-Id: 565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp2180283pxh; Tue, 16 Aug 2022 11:54:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR6y48ClrMNiCYgZypTsX1s76bswrz32kiTvPW25inhU5UP7B6vu/WswZ8K/dtqcw0OS+roR X-Received: by 2002:a17:906:668b:b0:730:a5b7:8985 with SMTP id z11-20020a170906668b00b00730a5b78985mr13900601ejo.548.1660676099651; Tue, 16 Aug 2022 11:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660676099; cv=none; d=google.com; s=arc-20160816; b=jeZMplW1CyzSrxXJxQmWoMoRjDHffdiomJyD/3ImLZL7EU/Xdsn1g6CYvtRmsCyfPT wjDgnvmCZpUSLp6QRCqQTnHGkGPhRzZL6mBKNGhz91QTxLQ/7rLeUHyrrH754Evjffoh P65BKfs9BXMnm4ljOQWKJVmLtPAaeRQWdnoDECiUaW9/D7yX+MYnjR0RIO0OMIjLBCOn OVl3UQNmjkqzZ3hYXZ7stZAR6CubNpnTKP2hQSEtMZHkSFQ7pxR201885IMalFaBMB35 /RbIAwZafk+nDzDlt+2M456YIV/fFyzqi9FhWpFb58YzSnUuPTF5r+Cv2r7jJ0TwhuOP WK2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :to:content-language:user-agent:mime-version:date:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=5G+4i9JjWc5xqvidHpC754N8x4tc7+z8UE9r8FjbM68=; b=l9qGGB/jSYH2quCPbJxIQIcyh9FhflQlfaUb58NNhEWruuqt3JPac4ZmDS35Fz8MY2 LNnojJsQUp8BTKDFSmDd9qD4qq7zZOT/pJqZdObbVWCBCeD4ZaSWFhEow5IXUwGSRRrL ZWfyFGyuLwudrAzrO9C3D+ezFxgmUqPmAJONsRnjCJHcmRNCo6fuuJv3xmfQN9tYRrr9 GETA1coQLNb4c89JqlBb2h6p5ZfUf31Lkxg0tSRkCCP3ou5CWCmj7derhMk5lQj/3MzI FZd3uwNfdw+up/OmS79G7wsqPgR+cXWftet9sCrvGFv1os57hR6muTsjD4/k5NTEM7p/ ZYwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CIYR5lHL; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id cs16-20020a170906dc9000b00738466b6883si6060995ejc.42.2022.08.16.11.54.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 11:54:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CIYR5lHL; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 453F63858288 for ; Tue, 16 Aug 2022 18:54:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 453F63858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660676098; bh=5G+4i9JjWc5xqvidHpC754N8x4tc7+z8UE9r8FjbM68=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CIYR5lHL6nOOHHfziUhb7ST9flZfJ2sAVda9AS3kYsJWNEi5XGnFdLWAOxqYbRshL /1JiR1fZtTtMYIb5UpDMuzB/b3MxyRAZTpnhbbAW2N1YEmeVZWMkJ1SCdk7Ngq15ER lO0sQ4WVUuEB0uydIYYp1Zl/kOec8GcccetTmtss= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 7EC903858CDA; Tue, 16 Aug 2022 18:54:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7EC903858CDA Received: by mail-wr1-x431.google.com with SMTP id p10so13685141wru.8; Tue, 16 Aug 2022 11:54:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=5G+4i9JjWc5xqvidHpC754N8x4tc7+z8UE9r8FjbM68=; b=ogw0si5DughqBSNELSPI0fwd+Baps7wHEVmxQkhlLGM90I/uISKrLKb5lAc2tCrj7f 2GOSqcyz1BLvvdDfUkO+jUCkEpCopcTd5QLChbSs4qaYb2gXqk8jFr7Z6VPsPb44Pg26 4gXQmC5/Ue3WmlC/Tm4tCNq/ffkrIAmTeAG2vVP4CW9IObnBVmVAqc8YqryZHwuAOuFU 7iNd2FqhW4+okBtX2LWaAF9G47yoSvL7W7YSKFmgonYIeDhQWEYepLjWXFSdOTsZmQOo NpbeNkv5ZjrzHxuCHR3KUzZ2Q8FRKnbAMuj2lCcXnORWeOjuP/cpB/w1uFrYmBsEihXr 0WoQ== X-Gm-Message-State: ACgBeo0RQvZqKPCsJzoqBU35f6YnoZBp9urena5Cgolx8JuYRhPKed3B DMPZm/2LNhcptIax+Dc9xQlJomn4D3A= X-Received: by 2002:a05:6000:783:b0:223:93d0:3286 with SMTP id bu3-20020a056000078300b0022393d03286mr12146495wrb.347.1660676050849; Tue, 16 Aug 2022 11:54:10 -0700 (PDT) Received: from ?IPV6:2a01:e0a:1dc:b1c0:8c9f:c361:c656:11e8? ([2a01:e0a:1dc:b1c0:8c9f:c361:c656:11e8]) by smtp.googlemail.com with ESMTPSA id m17-20020a05600c3b1100b003a319b67f64sm5505768wms.0.2022.08.16.11.54.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Aug 2022 11:54:10 -0700 (PDT) Message-ID: <285077ef-de58-6050-bba8-e59f01009c8b@gmail.com> Date: Tue, 16 Aug 2022 20:54:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: fr To: "libstdc++@gcc.gnu.org" Subject: [PATCH][_GLIBCXX_ASSERTIONS] Activate __glibcxx_requires_string/__glibcxx_requires_string_len X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fran=C3=A7ois_Dumont_via_Gcc-patches?= From: =?utf-8?q?Fran=C3=A7ois_Dumont?= Reply-To: =?utf-8?q?Fran=C3=A7ois_Dumont?= Cc: gcc-patches Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1741345102317486868?= X-GMAIL-MSGID: =?utf-8?q?1741345102317486868?= Following my remark about tests XFAIL-ing when running 'make check' I'd like to propose this to avoid this situation.     libstdc++: [_GLIBCXX_ASSERTIONS] Activate basic _GLIBCXX_DEBUB_PEDANTIC checks     Activate __glibcxx_requires_string/__glibcxx_requires_string_len in basic _GLIBCXX_ASSERTIONS     mode which is then considering _GLIBCXX_DEBUG_PEDANTIC for this purpose.     Thanks to this change add _GLIBCXX_ASSERTIONS to some tests that are otherwise XFAIL-ing on     segmentation fault rather than on a proper __glibcxx_assert call.     libstdc++-v3/ChangeLog:             * include/debug/debug.h (__glibcxx_requires_string, __glibcxx_requires_string_len): Move             definitions...             * include/debug/assertions.h: ... here. Definition now depends on _GLIBCXX_ASSERTIONS rather             than _GLIBCXX_DEBUG.             * testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc: Add _GLIBCXX_ASSERTIONS             define.             * testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc: Likewise.             * testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc: Likewise.             * testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc: Likewise. Tested under Linux x86_64. Ok to commit ? François diff --git a/libstdc++-v3/include/debug/assertions.h b/libstdc++-v3/include/debug/assertions.h index 57c0ab2c3cf..fcc910c7396 100644 --- a/libstdc++-v3/include/debug/assertions.h +++ b/libstdc++-v3/include/debug/assertions.h @@ -43,6 +43,8 @@ # define __glibcxx_requires_non_empty_range(_First,_Last) # define __glibcxx_requires_nonempty() # define __glibcxx_requires_subscript(_N) +# define __glibcxx_requires_string(_String) +# define __glibcxx_requires_string_len(_String,_Len) #else // Verify that [_First, _Last) forms a non-empty iterator range. @@ -53,6 +55,22 @@ // Verify that the container is nonempty # define __glibcxx_requires_nonempty() \ __glibcxx_assert(!this->empty()) +# ifdef _GLIBCXX_DEBUG_PEDANTIC +# if __cplusplus < 201103L +# define __glibcxx_requires_string(_String) \ + __glibcxx_assert(_String != 0) +# define __glibcxx_requires_string_len(_String,_Len) \ + __glibcxx_assert(_String != 0 || _Len == 0) +# else +# define __glibcxx_requires_string(_String) \ + __glibcxx_assert(_String != nullptr) +# define __glibcxx_requires_string_len(_String,_Len) \ + __glibcxx_assert(_String != nullptr || _Len == 0) +# endif // C++11 +# else +# define __glibcxx_requires_string(_String) +# define __glibcxx_requires_string_len(_String,_Len) +# endif // _GLIBCXX_DEBUG_PEDANTIC #endif #ifdef _GLIBCXX_DEBUG diff --git a/libstdc++-v3/include/debug/debug.h b/libstdc++-v3/include/debug/debug.h index f4233760426..5593b4fe92c 100644 --- a/libstdc++-v3/include/debug/debug.h +++ b/libstdc++-v3/include/debug/debug.h @@ -78,8 +78,6 @@ namespace __gnu_debug # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) # define __glibcxx_requires_heap(_First,_Last) # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) -# define __glibcxx_requires_string(_String) -# define __glibcxx_requires_string_len(_String,_Len) # define __glibcxx_requires_irreflexive(_First,_Last) # define __glibcxx_requires_irreflexive2(_First,_Last) # define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred) @@ -118,17 +116,6 @@ namespace __gnu_debug __glibcxx_check_heap(_First,_Last) # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \ __glibcxx_check_heap_pred(_First,_Last,_Pred) -# if __cplusplus < 201103L -# define __glibcxx_requires_string(_String) \ - _GLIBCXX_DEBUG_PEDASSERT(_String != 0) -# define __glibcxx_requires_string_len(_String,_Len) \ - _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0) -# else -# define __glibcxx_requires_string(_String) \ - _GLIBCXX_DEBUG_PEDASSERT(_String != nullptr) -# define __glibcxx_requires_string_len(_String,_Len) \ - _GLIBCXX_DEBUG_PEDASSERT(_String != nullptr || _Len == 0) -# endif # define __glibcxx_requires_irreflexive(_First,_Last) \ __glibcxx_check_irreflexive(_First,_Last) # define __glibcxx_requires_irreflexive2(_First,_Last) \ diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc index 7a7b8dd077d..6080ddc0555 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . // -// { dg-options "-std=gnu++2a -O0" } +// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" } // { dg-do run { target c++2a xfail *-*-* } } #define _GLIBCXX_DEBUG_PEDANTIC diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc index a6881bf406b..61d43558a74 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . // -// { dg-options "-std=gnu++2a -O0" } +// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" } // { dg-do run { target c++2a xfail *-*-* } } #define _GLIBCXX_DEBUG_PEDANTIC diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc index f357aef2289..e1cc8bad525 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . // -// { dg-options "-std=gnu++2a -O0" } +// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" } // { dg-do run { target c++2a xfail *-*-* } } #define _GLIBCXX_DEBUG_PEDANTIC diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc index 90065a459b6..8fc39bbd63c 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . // -// { dg-options "-std=gnu++2a -O0" } +// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" } // { dg-do run { target c++2a xfail *-*-* } } #define _GLIBCXX_DEBUG_PEDANTIC