The following program generates incorrect code for -sizeof(x):
char x; // Must be 129..255 to fail
This is the code generated:
; main.c 4
; Peephole 182 used 16 bit load of dptr
mov dptr,#(((0x00)<<8) + 0x7F)
The number should be negative, but as you can see a 0 is placed in the upper byte.
-sizeof() fails for structures/arrays in the range of 129 to 255.
The current workaround is to cast the expression to an int: