[Bug middle-end/103950] [9/10/11/12 Regression] printf("\xff") incorrectly optimized to putchar(-1)

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jan 24 03:03:46 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103950

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the reason why the standard is written this way is because in K&R C, every
function argument was promoted to int as there were no prototypes and then the
function would cast it back to char/unsigned char, etc. So this is carrying
forward backwards compatibility.

So again what GCC is doing is correct even if it seems wrong and the functions
(or macros) need to do the casting to follow the C standard and all.


More information about the Gcc-bugs mailing list