This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

--- 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;
 }

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]