From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2206) id E0D383858C54; Wed, 26 Jul 2023 11:43:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0D383858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690371796; bh=gycbK6YLiCGEx7pi9SuZ4HsAGH7sEifwQ97mmTRWBB8=; h=From:To:Subject:Date:From; b=XuiRD1rWzCA+UDGtVnqIXNFdiyxLsIzmNcIBZqGEWM/kmAVXDctPvKVXom4woi3ft M9tPDlSAKtbvnFFKN7jgu8PQ4nNYEm5ekoD5KZw1CaE0+jM3hKTUwD70anhEPzhD4F 0N7wgel/K9VSWTFoZv8oBnQjgQgr4E/atTctVvfU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Siddhesh Poyarekar To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-2789] testsuite/110763: Ensure zero return from test X-Act-Checkin: gcc X-Git-Author: Siddhesh Poyarekar X-Git-Refname: refs/heads/master X-Git-Oldrev: 8605bd9321010f15c471d511de5a06bbd9cc7c4b X-Git-Newrev: 386df7ce7b38ef00e28080a779ef2dfd6949cf15 Message-Id: <20230726114316.E0D383858C54@sourceware.org> Date: Wed, 26 Jul 2023 11:43:16 +0000 (GMT) List-Id: https://gcc.gnu.org/g:386df7ce7b38ef00e28080a779ef2dfd6949cf15 commit r14-2789-g386df7ce7b38ef00e28080a779ef2dfd6949cf15 Author: Siddhesh Poyarekar Date: Fri Jul 21 11:13:58 2023 -0400 testsuite/110763: Ensure zero return from test The test deliberately reads beyond bounds to exersize ubsan and the return value may be anything, based on previous allocations. The OFF test caters for it by ANDing the return with 0, do the same for the DYN test. gcc/testsuite/ChangeLog: PR testsuite/110763 * gcc.dg/ubsan/object-size-dyn.c (dyn): New parameter RET. (main): Use it. Signed-off-by: Siddhesh Poyarekar Diff: --- gcc/testsuite/gcc.dg/ubsan/object-size-dyn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/ubsan/object-size-dyn.c b/gcc/testsuite/gcc.dg/ubsan/object-size-dyn.c index 0159f5b9820..49c3abe2e72 100644 --- a/gcc/testsuite/gcc.dg/ubsan/object-size-dyn.c +++ b/gcc/testsuite/gcc.dg/ubsan/object-size-dyn.c @@ -5,12 +5,12 @@ int __attribute__ ((noinline)) -dyn (int size, int i) +dyn (int size, int i, int ret) { __builtin_printf ("dyn\n"); fflush (stdout); int *alloc = __builtin_calloc (size, sizeof (int)); - int ret = alloc[i]; + ret = ret & alloc[i]; __builtin_free (alloc); return ret; } @@ -28,7 +28,7 @@ off (int size, int i, int ret) int main (void) { - int ret = dyn (2, 2); + int ret = dyn (2, 2, 0); ret |= off (4, 4, 0);