bug-221220.c

来自「sdcc是为51等小型嵌入式cpu设计的c语言编译器支持数种不同类型的cpu」· C语言 代码 · 共 43 行

C
43
字号
/* bug-221220.c   Or an approximation there of.*/#include <testfwk.h>typedef struct {    int filler;    int value;} TESTSTRUCT;static voidincrementValue(TESTSTRUCT *ps){    ps->value++;}static voidsubTestStructVolatile(TESTSTRUCT *ps){    int a, b;    /* sdcc used to cache the value of ps->value into registers, such       that as a = ps->value and b = ps->value, then a = b.  However       if an intervening function uses the structure then ps->value       could change.    */    a = ps->value;    incrementValue(ps);    b = ps->value;    ASSERT(a == 7);    ASSERT(b == 8);}static voidtestStructVolatile(void){    TESTSTRUCT s;    s.value = 7;    subTestStructVolatile(&s);}

⌨️ 快捷键说明

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