Hello SDCC team,
I managed to lock down a broken scenario involving structs and function pointers.
If it affects all targets or just STM8 is unclear.
version: #9454
code:
typedef void (*t_func_type)(void); static void test_func(void) { } typedef struct { t_func_type func[2]; }t_test_struct; static t_test_struct g_test_struct = {{test_func}}; int main(void) { g_test_struct.func[0](); return 0; }
options:
--debug --disable-warning 110 --disable-warning 85 --Werror --std-sdcc89 --fverbose-asm --opt-code-size -mstm8 --std-sdcc89 --fverbose-asm
emitted code:
ldw x, #_g_test_struct+0 call (x)
problem:
It loads the correct address for "g_test_struct".
However it forgets to emit something like "ld (X),X" to derefence the pointer.
Changing just about anything makes it work.
2) 1) If you do not make it an array -> it works.
2) If you do not place the array in the struct -> it works.
But this specific combination does not work.
Any ideas?
Thanks,
/pedro
It affect all backends. All backends return wrong assembly code.
Any reason why you do not consider this to be a bug in the frontend? To me iCodes (and eBBlocks) are in the frontend.
For the record: you fixed it in [r9456].
i thought only the ast is the frontend. however that is not important.
:)