aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/memcheck/t5.c
blob: c3bbf640517d9870483bd05e92faadafd5ddd2f2 (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
/* Must define:
   int expect_error;
   void test ();
   void setup () NOCHECK; */

#include "driver.h"

int expect_error = 1;

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

struct s *sp;

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

int foo (struct s *sp)
{
  return sp->c + sp->a + sp->b;
}

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