]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite/110763: Ensure zero return from test
authorSiddhesh Poyarekar <siddhesh@gotplt.org>
Fri, 21 Jul 2023 15:13:58 +0000 (11:13 -0400)
committerSiddhesh Poyarekar <siddhesh@gotplt.org>
Wed, 26 Jul 2023 11:42:53 +0000 (07:42 -0400)
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

index 0159f5b982046d90b3296845ea51613a01679bb4..49c3abe2e72b36e23cd94b48907722adfc7f94a0 100644 (file)
@@ -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);