summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug3403429.c
blob: 5eb0bd42219a12deccfc384b9a71e2ecd99ec49e (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
55
56
57
58
59
60
61
62
63
64
65
66
/*
   bug3403429.c
*/

#include "testfwk.h"

void PTBL (signed char col, signed char row, unsigned char spN)
{
  col;
  row;
  spN;
}

signed char C [4+1][2+1];
unsigned int gm;

signed char i;

void Sub_9000 (void)
{
  {
    unsigned char i, j;
    for( i=0; i<=36; i+=4 )
    {
      for( j=0; j<=23; j+=8 )
      {
        PTBL(i,j,98);
        PTBL(30-i,20-j,98);
      }
    }
  }

  if( gm==0 )
  {
    C[ 1][1]=10; C[ 1][2]=10;
    C[ 2][1]=10; C[ 2][2]=10;
    C[ 3][1]=10; C[ 3][2]=10;
    C[ 4][1]=10; C[ 4][2]=10;

    for(i=4; i!=0; i--) // <-- BUG IS HERE
    {
      /* the calculation of the address of C[i] is pulled out of the loop
         and on top of that the local (out of scope) unsigned char i is used
         instead of the global signed char i */
      C[i][1]=0;
      C[i][2]=0;
    }
  }
}

void testBug(void)
{
  unsigned int i;

  i;

  gm = 0;

  Sub_9000();

  for(i = 1; i <= 4; i++)
    {
      ASSERT(C[i][1] == 0);
      ASSERT(C[i][2] == 0);
    }
}