Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug1505811.c
blobddb4e0ab864150cbb717ea6d9996eac552e0828f
1 /* bug 1505811
2 * demonstrates an incorrect "loopreverse"
3 * note func0, is a kind of safeguard, the incorrect code
4 * will access indices 0 and 1 instead of 1 and 2,
5 * and with incorrect order
6 */
8 #include <testfwk.h>
10 char glbl;
12 void func0() { glbl = 0; }
13 void func1() { glbl = 1; }
14 void func2() { glbl = 2; }
16 typedef void (*fptr)();
18 fptr ep_init[3] = { func0, func1, func2 };
20 void buggy()
22 unsigned char i;
23 for(i = 1; i <= 2; i++)
25 ep_init[i]();
29 void
30 testBug(void)
32 buggy();
33 ASSERT(glbl == 2);