Patchwork [committed] Fix up 20071018-1.c testcase (PR testsuite/55504)

login
register
mail settings
Submitter Jakub Jelinek
Date Nov. 28, 2012, 4:30 p.m.
Message ID <20121128163018.GO2315@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/202503/
State New
Headers show

Comments

Jakub Jelinek - Nov. 28, 2012, 4:30 p.m.
Hi!

As discussed on IRC, this testcase clobbers memory before malloc returned
chunk, fixed thusly, tested on x86_64-linux, committed to trunk.

2012-11-28  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/55504
	* gcc.c-torture/execute/20071018-1.c (foo): Add noinline/noclone
	attributes.  Avoid clobbering memory before malloced chunk.
	(main): Pass 1 instead of 0 as argument.


	Jakub

Patch

--- gcc/testsuite/gcc.c-torture/execute/20071018-1.c.jj	2008-09-05 12:54:12.000000000 +0200
+++ gcc/testsuite/gcc.c-torture/execute/20071018-1.c	2012-11-28 13:42:10.583890553 +0100
@@ -13,11 +13,11 @@  void __attribute__((noinline)) bar(struc
 {
   *f = __builtin_malloc(sizeof(struct foo));
 }
-struct foo * foo(int rank)
+struct foo * __attribute__((noinline, noclone)) foo(int rank)
 {
   void *x = __builtin_malloc(sizeof(struct mem));
   struct mem *as = x;
-  struct foo **upper = &as->x[rank * 8 - 1];
+  struct foo **upper = &as->x[rank * 8 - 5];
   *upper = 0;
   bar(upper);
   return *upper;
@@ -25,7 +25,7 @@  struct foo * foo(int rank)
 
 int main()
 {
-  if (foo(0) == 0)
+  if (foo(1) == 0)
     abort ();
   return 0;
 }