* Optimised many of the library functions
[fw/sdcc] / support / regression / tests / bug-221100.c
1 /* bug-221100.c
2
3    If test_index is char, loses high bit when indexes table 
4    workaround is to use [(unsigned int) test_index] 
5  */
6 #include <testfwk.h>
7
8 static unsigned int
9 testArray[130];
10
11 static unsigned int test_int ; 
12 static unsigned char test_index ; 
13
14 static void 
15 fetch(void) 
16
17   test_int = testArray [test_index] ; 
18
19
20 static void
21 testUnsignedCharIndex(void)
22 {
23   int i;
24   for (i = 0; i < 130; i++) {
25     testArray[i] = i;
26   }
27
28   test_index = 5;
29   fetch();
30   ASSERT(test_int == 5);
31
32   test_index = 129;
33   fetch();
34   ASSERT(test_int == 129);
35 }