summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2628.c
blob: 70de5c1b7e94a439fee8f69f53a558b43704558f (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
41
42
43
44
45
46
47
48
/*
  bug-2628.c, fetchLitPair() overwrites live IY register
*/

#include <testfwk.h>

struct list {
  struct list *next;
  void *p;
};

void *data;
static struct list *base;

static void
add(struct list *e)
{
  struct list *l;

  if(e->p != 0) {
    for(l = base; l != 0; l = l->next) {
      if(l == e) {
        e->p = data;
	return;
      }
    }
  }

  e->p = data;
}

void
testBug(void)
{
  static int d = 1234;
  struct list e;
  volatile void *tmp;

  data = &d;
  base = 0;

  add (&e);

  tmp = e.p;

  ASSERT(e.p == data);
}