Closed flozz closed 5 years ago
Since 2016, the char type is unsigned by default in SDCC. From the SDCC ChageLog:
char
2016-02-01 Philipp Klaus Krause <pkk AT spth.de> * src/SDCCglobl.h, src/SDCCmain.c, src/SDCCsymt.c, src/SDCCval.c, doc/sdccman.lyx: Make char unsigned by default.
As the INT8 type is based on char, this make it unsigned...
INT8
This PR fixes the issue. There is also an other possible fix: using the --fsigned-char option of the compiler.
--fsigned-char
Here a small code that reproduce the issue:
#include <stdio.h> #include <gb/gb.h> void main(void) { INT8 x = 10; INT8 dx = -1; printf("INT8 x = 10;\n"); printf("INT8 dx = -1;\n\n"); printf("x + dx = %i\n", x + dx); }
Result before the fix:
And after the patch:
Nice find! Thanks a lot!
Since 2016, the
char
type is unsigned by default in SDCC. From the SDCC ChageLog:As the
INT8
type is based onchar
, this make it unsigned...This PR fixes the issue. There is also an other possible fix: using the
--fsigned-char
option of the compiler.Here a small code that reproduce the issue:
Result before the fix:
And after the patch: