mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
added test for issue #1108
This commit is contained in:
parent
78342fa82c
commit
5a9d76ad52
40
test/val/bug1108.c
Normal file
40
test/val/bug1108.c
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
/* bug #1108 - Problem with static locals? */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#pragma static-locals (on)
|
||||||
|
|
||||||
|
unsigned char x = 0;
|
||||||
|
|
||||||
|
unsigned char PrintVar1(void)
|
||||||
|
{
|
||||||
|
unsigned char cx = x + 1;
|
||||||
|
printf("cx:%d x:%d\n", cx, x);
|
||||||
|
return cx == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char PrintVar2(void)
|
||||||
|
{
|
||||||
|
unsigned char cx = x + 1;
|
||||||
|
unsigned char cy;
|
||||||
|
cy = x + 1;
|
||||||
|
printf("cx:%d cy:%d x:%d\n", cx, cy, x);
|
||||||
|
return cx != cy;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma static-locals (off)
|
||||||
|
|
||||||
|
unsigned char n;
|
||||||
|
unsigned char ret = 0;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
for (n = 0; n < 10; n++) {
|
||||||
|
++x;
|
||||||
|
ret |= PrintVar1();
|
||||||
|
ret |= PrintVar2();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user