projects
/
fw
/
sdcc
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
* support/regression/tests/bug-477927.c: Added.
[fw/sdcc]
/
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
void
33
testLoopInit(void)
34
{
35
UBYTE t, r;
36
37
do {
38
r = randish();
39
40
if(r != 1) {
41
t = ++accu[r];
42
spoil(t);
43
}
44
}
45
while(t != 3);
46
}
47
48