aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/memcheck/t7.c
blob: a7c6f5127ed8584bcb7149aca0aba87e254159bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Must define:
   int expect_error;
   void test ();
   void setup () NOCHECK; */

#include "driver.h"

int expect_error = 0;

struct s {
  char c;
  int a, b;
};

struct s *sp;

void test ()
{
  sp = c_malloc (sizeof (struct s) * 2);
  sp->c = 0;
  sp->a = 13;
  sp->b = 47;
  cp (sp);
  foo (sp);
}

int foo (struct s *sp)
{
  return sp[1].c + sp[1].a + sp[1].b;
}

int cp (struct s *sp)
{
  sp[1] = sp[0];
}

void setup () /* NOCHECK */
{
  mark_region (&sp, sizeof (sp), ACCESS_RW);
}