From 5a9d76ad5211c944d5ef004c5742139f8cdc8dcd Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 20 Jul 2020 15:50:11 +0200 Subject: [PATCH] added test for issue #1108 --- test/val/bug1108.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/val/bug1108.c diff --git a/test/val/bug1108.c b/test/val/bug1108.c new file mode 100644 index 000000000..17ef022c3 --- /dev/null +++ b/test/val/bug1108.c @@ -0,0 +1,40 @@ + +/* bug #1108 - Problem with static locals? */ + +#include + +#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; +} +