public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix up 20071018-1.c testcase (PR testsuite/55504)
@ 2012-11-28 16:31 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2012-11-28 16:31 UTC (permalink / raw)
  To: gcc-patches

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-11-28 16:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-28 16:31 [committed] Fix up 20071018-1.c testcase (PR testsuite/55504) Jakub Jelinek

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).