For the following code:
void *foo[]={(void *)&("X"[0])};
sdcc generates two casts and an assignment and iTemps. This is
1) Ineffcient, since all calculations could be done at compile time instead
2) Dangerous, since other parts of sdcc, i.e. register allocation and code generation do not expect iTemps outside of functions. The Z80 related ports can handle them if they go into registers, and I just added an assertion in case they go onto the stack (so there is more than just the SIGSEGV to the user).
I see this issue in revision #7530, and found it by using --max-allocs-per-node 10 in the gcc-torture-execute-921019-1.c regression test when compiling for gbz80. I hive this above-default priority, since I suspect, this can result in silent generation of bad code if we don't get a SIGSEGV in other ports.
Philipp
In current SDCC [r10516], this problem is no longer as common as it used to be. Now, it only happens for static local variables, e.g.
Philipp
Currently code generated for Z80, GBZ80, eZ80 is valid: all computations are done on compile stage. I think, this bug can be closed.
Yes, looks like it got fixed a while ago.