From patchwork Fri Jun 9 18:28:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Lange X-Patchwork-Id: 105753 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1105389vqr; Fri, 9 Jun 2023 11:30:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WcrsAul+PlBRgTmDIqK46A+TaAPg59HMTjYrTMw/GICFB2kf65uyzvCKrrUQoS6hj3EfQ X-Received: by 2002:a17:907:31c8:b0:978:62c1:6b4f with SMTP id xf8-20020a17090731c800b0097862c16b4fmr2195773ejb.12.1686335456875; Fri, 09 Jun 2023 11:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686335456; cv=none; d=google.com; s=arc-20160816; b=OOVpTQik5b5wrGEuFKplgS1W1PmDu9VyTx79uhIKr8BlyLK6V+2jR5J673K9nTj5KN Ygs3dlKcMDS11bl1vCLy+bYxPvCYcYIvcV8lqQyFVqB8E3yCe8Wrirc0vrvjzukiA4jj JZVFQLVSgotis/O7847Hrw/Th+sUmGr+ToVp6IkP9+qG2+CE979vO38y1/F3RFxCOPtc 4oWPwuTut6RxutFKawmPvPu4nROjcEIrLbuxqYl24IbzkwwUGjMErZ02l4SWX/Mt+1G5 xVw555Q8J47EvtwyVA+/C+GnsMOozU5GtV3RXlWLrfKhn4ky9zzjDdPldD5tFt9OBHdj RoWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=4n+HuDYcHuYN/Jm1XGi4FEp6vqsDJZ2UbxAD7BNgKwM=; b=OxwjwI1sISKz6NyXb2xRkTMvMtLdv7w3ApnpMIdOXvnUaUjuYvWztnDi60DHXAcAUE xLW/MW2YqhE1CjA3/psL0Mn4MQ9JdvPNLJEKRjuEkcAhyuhnyTGkMdQN3bwkVBLpWZ38 AJgKO93X9a3DDAi3+Xj9SwJ75tuK7PCjyFwOl/bzRf8Sz9Lg0dpqSiVHabuo/LE3yy0x SfjPcznQ2CASanqHcB5F8z72gmrYQfYm7Zo5yedpay/ka4ixVBr8Oz2pqxshkacMXGg3 l2xfm2ENpo3BcbswCUeAhOyG0Lwbl8hNcN1/DVCi6XQwwYFV2u0JKpz2xT1O6dRHrmy3 CDxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@tim-lange.me header.s=default2108 header.b=EZdV6MlA; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id dk17-20020a170906f0d100b009746026a32fsi1919559ejb.995.2023.06.09.11.30.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 11:30:56 -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=fail header.i=@tim-lange.me header.s=default2108 header.b=EZdV6MlA; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2841A38558BB for ; Fri, 9 Jun 2023 18:30:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from www523.your-server.de (www523.your-server.de [159.69.224.22]) by sourceware.org (Postfix) with ESMTPS id 5701B3856969 for ; Fri, 9 Jun 2023 18:29:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5701B3856969 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tim-lange.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tim-lange.me DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tim-lange.me; s=default2108; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=4n+HuDYcHuYN/Jm1XGi4FEp6vqsDJZ2UbxAD7BNgKwM=; b=EZdV6MlAiV6YdviZz62pY6KGUB z1UOziQyJjOS3vWoe/ggNHMGemG0snLJjFB+CY0wp1Xk4tPPLmL/JmKqt/znBs+Iufdix71UB+Y1O K/X2QlledR1K9BRrM7AAIGhFNcyjaw2MEvhWAtcC567UhgUlmMzcsHxwTl5WGCv8m8/MzC47ilH2B w1BAx0zUITuJsiRGyDrvIpQAWHtXnZ+y3HCrPaekzgmTNy5ThjufvpSfDCMUKejbZKCwMfG2/K8TJ 9ehtfzXHtiUhLBcCyZH6rOhLTNXdH71It7sbTYVK3Akfe7+weT04moieq27bLTXLHHW2IQAx1KZ5b z0UUxURA==; Received: from sslproxy03.your-server.de ([88.198.220.132]) by www523.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q7grj-000Nzk-9b; Fri, 09 Jun 2023 20:29:39 +0200 Received: from [2a02:908:1861:d6a0::7959] (helo=workstation..) by sslproxy03.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q7grj-000ROv-1h; Fri, 09 Jun 2023 20:29:39 +0200 From: Tim Lange To: dmalcolm@redhat.com, gcc-patches@gcc.gnu.org Cc: Tim Lange Subject: [PATCH 2/2] testsuite: Add more allocation size tests for conjured svalues [PR110014] Date: Fri, 9 Jun 2023 20:28:13 +0200 Message-Id: <20230609182813.72319-2-mail@tim-lange.me> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609182813.72319-1-mail@tim-lange.me> References: <20230609182813.72319-1-mail@tim-lange.me> MIME-Version: 1.0 X-Authenticated-Sender: mail@tim-lange.me X-Virus-Scanned: Clear (ClamAV 0.103.8/26934/Fri Jun 9 09:25:21 2023) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, 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: , 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?1768250888429250201?= X-GMAIL-MSGID: =?utf-8?q?1768250888429250201?= This patch adds the reproducers reported in PR 110014 as test cases. The false positives in those cases are already fixed with PR 109577. 2023-06-09 Tim Lange PR analyzer/110014 gcc/testsuite/ChangeLog: * gcc.dg/analyzer/pr110014.c: New tests. --- gcc/testsuite/gcc.dg/analyzer/pr110014.c | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/analyzer/pr110014.c diff --git a/gcc/testsuite/gcc.dg/analyzer/pr110014.c b/gcc/testsuite/gcc.dg/analyzer/pr110014.c new file mode 100644 index 00000000000..d76b8781413 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr110014.c @@ -0,0 +1,25 @@ +void *realloc (void *, unsigned long) + __attribute__((__nothrow__, __leaf__)) + __attribute__((__warn_unused_result__)) __attribute__((__alloc_size__ (2))); + +long * +slurp (long *buffer, unsigned long file_size) +{ + unsigned long cc; + if (!__builtin_add_overflow (file_size - file_size % sizeof (long), + 2 * sizeof (long), &cc)) + buffer = realloc (buffer, cc); + return buffer; +} + +long * +slurp1 (long *buffer, unsigned long file_size) +{ + return realloc (buffer, file_size - file_size % sizeof (long)); +} + +long * +slurp2 (long *buffer, unsigned long file_size) +{ + return realloc (buffer, (file_size / sizeof (long)) * sizeof (long)); +}