Am 19.05.20 um 23:37 schrieb Basil Hussain:
> Here's a self-contained example that I can replicate the issue with:
> 
> #include <stdint.h>
> uint8_t foo(uint16_t value) {
>     return value;
> }
> uint8_t bar(uint16_t value) {
>     return (value ? foo(value) + 1 : 0);
> }
> void main(void) {
>     uint8_t x = bar(0xFF);
> }
> 
> Compiled with:
> sdcc.exe -mstm8 --std-c99 -I"C:\Program Files\SDCC\include" test.c

And using --i-code-in-asm --fverbose-asm shows that for some reason,
foo(vlaue) + 1 is calculated as a signed char, then cast to signed int.
Clearly, this shouldn't happen.
Fortunately, when the return value of bar is changed to uint16_t that
weird signed char stuff goes away (otherwise there would be a real bug
here resulting in wrong return values).

I'd suggest to file a feature request in the tracker, so this
inefficiency won't be forgotten.

Philipp


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to