Hello SDCC team,
Found this in some of my code:
uint32_t global; void func(void) { uint8_t i=18; uint8_t bit; bit = (BOOL)((global & (((uint32_t)1) << i)) && TRUE); if(bit) { while(1); }
Compiling this gives: "unreachable code"
The reason is the "i" variable which is only 8 bit. However, as the "1" is already casted, this should not matter.
What is worse, if the "i" variable is not a constant (e.g. comes from a function call), the code can build, but bad code is emitted. All bits above 8 are broken.
I think there are some general rules for casts that do not work here.
Thanks,
/pedro
Thanks to Peter's patch and Philipp' help. :)