public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] testsuite/110763: Ensure zero return from test
@ 2023-07-21 15:16 Siddhesh Poyarekar
  2023-07-22  5:05 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Siddhesh Poyarekar @ 2023-07-21 15:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: rguenther

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 <siddhesh@gotplt.org>
---
 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);
 
-- 
2.41.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] testsuite/110763: Ensure zero return from test
  2023-07-21 15:16 [PATCH] testsuite/110763: Ensure zero return from test Siddhesh Poyarekar
@ 2023-07-22  5:05 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2023-07-22  5:05 UTC (permalink / raw)
  To: Siddhesh Poyarekar, gcc-patches; +Cc: rguenther



On 7/21/23 09:16, Siddhesh Poyarekar wrote:
> 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.
OK
jeff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-22  5:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21 15:16 [PATCH] testsuite/110763: Ensure zero return from test Siddhesh Poyarekar
2023-07-22  5:05 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).