bug-477927.c

来自「Small Device C Compiler 面向Inter8051」· C语言 代码 · 共 49 行

C
49
字号
/* Tests an uninitalised variable bug.   t is not initalised in all paths in the do loop, causing the while   conditional to fail unpredictably.   Doesn't actually test, is really an example. */#include <testfwk.h>typedef unsigned char UBYTE;UBYTErandish(void){  static int count;  if ((++count)&3) {    return 1;  }  else {    return 0;  }}voidspoil(UBYTE ignored){  UNUSED(ignored);}UBYTE accu[2];void testLoopInit(void){  UBYTE t, r;  do {    r = randish();    if(r != 1) {      t = ++accu[r];      spoil(t);    }  }  while(t != 3);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?