struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-477927.c
blob3b78131d07d2f8c0a774c3fb9ba52a1d159f393f
1 /* Tests an uninitialised variable bug.
2 t is not initialised in all paths in the do loop, causing the while
3 conditional to fail unpredictably.
5 Doesn't actually test, is really an example.
6 */
7 #include <testfwk.h>
9 typedef unsigned char UBYTE;
11 UBYTE
12 randish(void)
14 static int count;
16 if ((++count)&3) {
17 return 1;
19 else {
20 return 0;
24 void
25 spoil(UBYTE ignored)
27 UNUSED(ignored);
30 UBYTE accu[2];
32 #if !defined(PORT_HOST)
33 # pragma disable_warning 84
34 #endif
36 void
37 testLoopInit(void)
39 UBYTE t, r;
41 do {
42 r = randish();
44 if(r != 1) {
45 t = ++accu[r];
46 spoil(t);
49 while(t != 3);