Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / bug1618050.c
1 /** bug 1618050
2  *    global variable px in function buggy, is marked rematr..
3  *    and is erronously assumed to retain its value "x" across
4  *    the function call to fiddle_px
5  */
6
7 #include <testfwk.h>
8
9 _STATMEM char * data px;
10 _STATMEM char x[2] = {0,42};
11
12 void fiddle_px(_STATMEM char * unused) {
13   (volatile char) unused[0]; // shut up
14   px++;
15 }
16
17 char buggy(void) {
18   px = x;
19   fiddle_px(x);
20   return *px;
21 }
22
23 void
24 testBug(void) {
25   ASSERT(buggy() == 42);
26 }