Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / bug-477927.c
1 /* Tests an uninitalised variable bug.
2    t is not initalised in all paths in the do loop, causing the while
3    conditional to fail unpredictably.
4
5    Doesn't actually test, is really an example.
6  */
7 #include <testfwk.h>
8
9 typedef unsigned char UBYTE;
10
11 UBYTE
12 randish(void)
13 {
14   static int count;
15
16   if ((++count)&3) {
17     return 1;
18   }
19   else {
20     return 0;
21   }
22 }
23
24 void
25 spoil(UBYTE ignored)
26 {
27   UNUSED(ignored);
28 }
29
30 UBYTE accu[2];
31
32 #if !defined(PORT_HOST)
33 #  pragma disable_warning 84
34 #endif
35
36 void 
37 testLoopInit(void)
38 {
39   UBYTE t, r;
40
41   do {
42     r = randish();
43
44     if(r != 1) {
45       t = ++accu[r];
46       spoil(t);
47     }
48   }
49   while(t != 3);
50 }