For the attached function, sdcc #6854 generates invalid asm code for additions in the z80 port (other ports, such as gbz80 are not affected). The problem goes away when suing --oldralloc. Resulting in assembler errors "Error: <a> machine specific addressing or addressing mode error".
The invalid isntructions are of the following types:
(undocumented instructions sdcc should currently not emit)
(I don't know any Z80 variant that would allow this)
To reproduce, compile the attached code using sdcc -mz80 --std-c99 test.c.