1 /** Test type cast with function pointers in array initialization.
7 /* don't spam the output with "pointer types incompatible" warnings */
8 #pragma disable_warning 244
13 typedef void (*fp
)(void);
15 void testFptrCastOld(void)
17 /* old functionality */
22 fp tab3
[2] = {(fp
)a
, 0};
24 fp tab4
[2] = {(fp
)&a
, 0};
26 /* sizeof(void *) < sizeof(fp) implies undefined behavior,
27 * i.e. the result of the comparison does not matter */
28 void * tab5
[2] = {a
, 0};
29 ASSERT(sizeof(void *) < sizeof(fp
) || ((fp
)tab5
[0]) == a
);
30 void * tab6
[2] = {&a
, 0};
31 ASSERT(sizeof(void *) < sizeof(fp
) || ((fp
)tab6
[0]) == a
);
34 void testFptrCastNew(void)
36 /* new functionality */
37 void * tab1
[2] = {(void*)a
, 0};
38 ASSERT(sizeof(void *) < sizeof(fp
) || ((fp
)tab1
[0]) == a
);
39 void * tab2
[2] = {(void*)&a
, 0};
40 ASSERT(sizeof(void *) < sizeof(fp
) || ((fp
)tab2
[0]) == a
);
41 char * tab3
[2] = {(char*)a
, 0};
42 ASSERT(sizeof(char *) < sizeof(fp
) || ((fp
)tab3
[0]) == a
);
43 char * tab4
[2] = {(char*)&a
, 0};
44 ASSERT(sizeof(char *) < sizeof(fp
) || ((fp
)tab4
[0]) == a
);