1 /*
2   bug-2548.c
3 */
4 
5 #include <testfwk.h>
6 
cmp_eq(long arg1,long arg2)7 static int cmp_eq (long arg1, long arg2)
8 {
9     return arg1 != arg2;
10 }
11 struct op {
12     const char *op_name;
13     void (*op_func)(void);
14 };
15 
16 /* In initializations, SDCC did not allow some function pointer casts allowed by the standard. */
17 
18 const struct op string_binop1[] = {
19     {"=", (void (*)(void*))cmp_eq},
20 };
21 
22 const struct op string_binop2[] = {
23     {"=", (void (*)(void*))&cmp_eq},
24 };
25 
testBug(void)26 void testBug(void)
27 {
28 #if !defined(__SDCC_mcs51) && !defined(__SDCC_ds390) && !defined(__SDCC_hc08) && !defined(__SDCC_s08) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) /* mcs51, hc08, s08 and pdk14 have restrictions on function pointers wrt. reentrancy */
29 	ASSERT(((int (*)(long, long))(string_binop1[0].op_func))(1, 1) == 0);
30 	ASSERT(((int (*)(long, long))(string_binop1[0].op_func))(1, 2) == 1);
31 	ASSERT(((int (*)(long, long))(string_binop2[0].op_func))(1, 1) == 0);
32 	ASSERT(((int (*)(long, long))(string_binop2[0].op_func))(1, 2) == 1);
33 #endif
34 }
35 
36