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: 56793 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 470993858438 for ; Tue, 16 Aug 2022 18:54:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 470993858438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660676084; 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=MB3uxc6KIGYi6WRU1nEMLICfiDaH+lXBAPinBujLPZ1i1ntodn2uDyuo7sQtZjocc NCQrgilbOmzaaU7pUZv0BqGROsDsEVPUSH5AAbG9ZR7wvNufRihba6gz0KTa+hO136 4OZz/uX6VsVVdWeyAWL+3JwGg8aGh2el4IqK0BSM= 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-Google-Smtp-Source: AA6agR71ZZ1CRKj+JJDNykkLKkJjmsQexee4wefT87gLE7zrJPdnkFRfNos56S2SI1j3rD0B7yiT/Q== 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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