📄 bug-221220.c
字号:
/* 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -