From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121451 invoked by alias); 21 Nov 2019 18:09:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 121441 invoked by uid 89); 21 Nov 2019 18:09:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1798 X-HELO: mail-pf1-f194.google.com Received: from mail-pf1-f194.google.com (HELO mail-pf1-f194.google.com) (209.85.210.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Nov 2019 18:09:28 +0000 Received: by mail-pf1-f194.google.com with SMTP id p24so2101905pfn.4 for ; Thu, 21 Nov 2019 10:09:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=ud9rCOr4avuB8L4aRNUjAiwusWhPNZ263EY3Fd1ySck=; b=F4X5GBqoKQEFeJDx52jywt/IQah4V2PFUli+zoKYWfbkgEEPbmsclckTQUuOeaTigP XI6LT9R5wB8K0OJbszmvIGgFQFOeOqNSszUuLwecl4omSG/VC2u0Nqd5jpH+EEhyvmFQ JHkaP8dVwQLpU+yY/vTkB+Gphq1BmPjG1ilc8lNWVm6znSzLtvzDerI/AB25xyU4kmpW ALq+5ITb3007/3WQKImJMqa77D17x3ISXrlM5N8YHEFNXiyPraY+EJ/3ja3Y0KAOL41M c1Po/GXd4bjseh/9uh18m7O77WtMK7f6VusPFeFhUIe9aSwCveZ2XQviMgcIjRBAe5NG B/Lw== Return-Path: Received: from [192.168.0.41] (97-118-98-145.hlrn.qwest.net. [97.118.98.145]) by smtp.gmail.com with ESMTPSA id z4sm4051346pfn.80.2019.11.21.10.09.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2019 10:09:25 -0800 (PST) Subject: Re: [PATCH] testsuite: Fix array size in gcc.dg/strlenopt-66.c To: Dimitar Dimitrov , gcc-patches@gcc.gnu.org References: <20191121171159.21853-1-dimitar@dinux.eu> From: Martin Sebor Message-ID: Date: Thu, 21 Nov 2019 18:22:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20191121171159.21853-1-dimitar@dinux.eu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-11/txt/msg02135.txt.bz2 On 11/21/19 10:11 AM, Dimitar Dimitrov wrote: > One of the passed arguments is actually a string with size 4 ("123"). > Adjust the destination buffer accordingly. > > gcc/testsuite/ChangeLog: > > 2019-11-21 Dimitar Dimitrov > > * gcc.dg/strlenopt-66.c (test_strncmp_a4_cond_a5_a3_n): Fix array size. > > Signed-off-by: Dimitar Dimitrov > --- > gcc/testsuite/gcc.dg/strlenopt-66.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/testsuite/gcc.dg/strlenopt-66.c b/gcc/testsuite/gcc.dg/strlenopt-66.c > index 4ba31a845b0..3de22c18f4f 100644 > --- a/gcc/testsuite/gcc.dg/strlenopt-66.c > +++ b/gcc/testsuite/gcc.dg/strlenopt-66.c > @@ -88,7 +88,7 @@ __attribute__ ((noclone, noinline, noipa)) void > test_strncmp_a4_cond_a5_a3_n (const char *s1, const char *s2, const char *s3, > int i, unsigned n) > { > - char a3[3], a4[4], a5[5]; > + char a3[4], a4[4], a5[5]; That does look like a mistake. Thanks for bringing it up! The purpose of the test is to exercise strncmp calls whose first two arguments involve arrays of all different sizes (and strings of different lengths stored in them). In this function, the operands of the conditional expression should also be of different sizes than the first argument: one should be smaller and the other bigger. So to keep the test doing what it's meant to do I think we need to change lengths of the strings passed to the function to fit the arrays rather than the sizes of the locals. (Adding even more calls to cover all the permutations of lengths and sizes would be a further improvement.) If this sounds too elaborate let me know and I'll fix the test. Martin > strcpy (a3, s1); > strcpy (a4, s2); > strcpy (a5, s3); >