struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug3564104.c
blob494f8e41813b7d5f22abcfae3919425a1e9eac9c
1 /*
2 bug3564104.c
3 */
5 #include <testfwk.h>
7 #include <stdint.h>
9 #ifdef __SDCC
10 #pragma disable_warning 127
11 #endif
13 uintptr_t array[4];
15 int i;
17 void g(const void *p)
19 array[i++] = (uintptr_t)(p);
22 void f1(uintptr_t base, const char *message)
24 for(; *message; message++)
25 g((const void *)(base + *message * 8));
28 void f2(uintptr_t base, const char *message)
30 for(; *message; message++)
32 volatile uintptr_t tmp = base + *message * 8;
33 g((const void *)(tmp));
37 void testBug(void)
39 char a[] = {10, 20, 30, 40, 0};
41 i = 0;
42 f1(0, a);
44 ASSERT(array[0] == 10 * 8);
45 ASSERT(array[1] == 20 * 8);
46 ASSERT(array[2] == 30 * 8);
47 ASSERT(array[3] == 40 * 8);
49 i = 0;
50 f2(0, a);
52 ASSERT(array[0] == 10 * 8);
53 ASSERT(array[1] == 20 * 8);
54 ASSERT(array[2] == 30 * 8);
55 ASSERT(array[3] == 40 * 8);