summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug2862308.c
blob: cc6ed38f0b2f6cefbb54d0bcc98cf8b1236dc6b8 (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
49
50
51
52
53
54
/*
   bug2862308.c
*/

#include <testfwk.h>

char case1(void)
{
  char j = 0;
  char *z = &j;

  j = 1;

  if (j)
    return 1;
  else
    return 0; /* We incorrectly end up here when using '*z' instead of '*(char *) &j'. */
}

char case2(void)
{
  char j = 0;
  char *z = &j;

  j = 1;

  if (*(char *) &j) /* Does *not* work with:
                     * sdcc -mmcs51 --model-large sample.c */
    return 1;
  else
    return 0; /* We incorrectly end up here when using '*z' instead of '*(char *) &j'. */
}

char case3(void)
{
  char j = 0;
  char *z = &j;

  j = 1;

  if (*z) /* Does *not* work with:
           * sdcc -mmcs51 --model-large sample.c
           * sdcc -mmcs51 sample.c */
    return 1;
  else
    return 0; /* We incorrectly end up here when using '*z' instead of '*(char *) &j'. */
}

void testBug(void)
{
  ASSERT(case1());
  ASSERT(case2());
  ASSERT(case3());
}