From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 510113858D1E; Sun, 14 Aug 2022 15:32:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 510113858D1E Received: by mail-wm1-x333.google.com with SMTP id bd26-20020a05600c1f1a00b003a5e82a6474so1176830wmb.4; Sun, 14 Aug 2022 08:32:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc; bh=4bVI+WkoGXd8L2gYFwnYuHZ7XVd9LjSJi752ByM80Uk=; b=CZGC83HfdhnkJDCPfMtOhMtmuZr60oDMDmzDUTBDOcxNYrEXueUSdaCn9D6e1JtoKq F93ny1Y415MDpNQA/C2eRZUGPtlZ65mIX7PIaLf+IaW3lN6CfIjhCdIuyT0zfbnDo+uI 8rOGlQlsToHPfG42Omy9amvVm8RcmhTVfkRQUDHm13zPexHNJskWnU3vx3HshJxheQOQ 8Jn5njlLQH4gQRk8NZSwKpWS5WoIghnG4kSwPjwC3LkfP0PvFHR9Cnmd10KOHxXMPd8S 3ZnXL/s6LRvuUyGe4eFJvmS7gDuV2Do0rY6ke7UnsfeOp6tijCjild6ftScd5Xg32cIH uNMA== X-Gm-Message-State: ACgBeo2hXMFdnAYdPXl3IzaxXR/1kSAtpEVOpryvlrISS3CGWzVywhWi pjrR+SQXOAOAiPnnj0ys/nl1d9D5CeY= X-Google-Smtp-Source: AA6agR7y4mIpaoeNXILqIrabuUCUHhuiMJlz8+EFmoEAKymdKOCkFwaInzHV12bR+Hw5pWtycUlzbQ== X-Received: by 2002:a05:600c:a199:b0:3a5:dddf:ac6d with SMTP id id25-20020a05600ca19900b003a5dddfac6dmr4172723wmb.44.1660491171698; Sun, 14 Aug 2022 08:32:51 -0700 (PDT) Received: from ?IPV6:2a01:e0a:347:cc80:685c:7181:c8d5:374e? ([2a01:e0a:347:cc80:685c:7181:c8d5:374e]) by smtp.googlemail.com with ESMTPSA id r6-20020adff706000000b00224f7886c48sm3279550wrp.47.2022.08.14.08.32.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 14 Aug 2022 08:32:51 -0700 (PDT) Message-ID: Date: Sun, 14 Aug 2022 17:32:50 +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" Cc: gcc-patches From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= Subject: [PATCH][_GLIBCXX_DEBUG] Add basic_string::starts_with/ends_with checks Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Aug 2022 15:32:55 -0000 I think we can add those checks. Note that I wonder if it was needed as in basic_string_view I see usages of __attribute__((__nonnull__)). But running the test I saw no impact even after I try to apply this attribute to the starts_with/ends_with methods themselves. Also note that several checks like the ones I am adding here are XFAILS when using 'make check' because of the segfault rather than on a proper debug checks. Would you prefer to add dg-require-debug-mode to those ?     libstdc++: [_GLIBCXX_DEBUG] Add basic_string::starts_with/ends_with checks     Add simple checks on C string parameters which should not be null.     Review null string checks to show:     _String != nullptr     rather than:     _String != 0     libstdc++-v3/ChangeLog:             * include/bits/basic_string.h (starts_with, ends_with): Add __glibcxx_check_string.             * include/bits/cow_string.h (starts_with, ends_with): Likewise.             * include/debug/debug.h: Use nullptr rather than '0' in checks in C++11.             * include/debug/string: Likewise.             * testsuite/21_strings/basic_string/operations/ends_with/char.cc: Use __gnu_test::string.             * testsuite/21_strings/basic_string/operations/ends_with/wchar_t.cc: Use __gnu_test::wstring.             * testsuite/21_strings/basic_string/operations/starts_with/wchar_t.cc: Use __gnu_test::wstring.             * testsuite/21_strings/basic_string/operations/starts_with/char.cc: Use __gnu_test::string.             * testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc: New test.             * testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc: New test.             * testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc: New test.             * testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc: New test. Tested under linux normal and debug modes. François