Doom64EX-Plus
Doom64EX-Plus copied to clipboard
GCC 13 overflow warning in p_user.c
Compiling under gcc 13 gives this overflow warning:
src/engine/p_user.c: In function ‘P_PlayerThink’:
src/engine/p_user.c:595:28: error: overflow in conversion from ‘int’ to ‘signed char’ changes value from ‘51200’ to ‘0’ [-Werror=overflow]
595 | cmd->forwardmove = 0xc800;
So this line is assigning 0xc800 to a signed char. Probably not what is wanted.
Compiling under gcc 13 gives this overflow warning:
src/engine/p_user.c: In function ‘P_PlayerThink’: src/engine/p_user.c:595:28: error: overflow in conversion from ‘int’ to ‘signed char’ changes value from ‘51200’ to ‘0’ [-Werror=overflow] 595 | cmd->forwardmove = 0xc800;
So this line is assigning 0xc800 to a signed char. Probably not what is wanted.
It's a error different from warning.
The trace above was because I was compiling with -Werror
(which makes all warnings to be error). Without -Werror
above message is a warning.
The trace above was because I was compiling with
-Werror
(which makes all warnings to be error). Without-Werror
above message is a warning.
Ok.
Nowadays i go carefully about warnings since some of them can be a false alarme to broke the code.
In anycase, compiler is telling it will be writing 0 to cmd->forwardmove
instead of 0xc800 because that member is signed char
.
So this really looks like a code logic error.
Author
i´ve made a review on your pull request, about __compar_fn_t
In anycase, compiler is telling it will be writing 0 to
cmd->forwardmove
instead of 0xc800 because that member issigned char
. So this really looks like a code logic error.
Unsigned char?
If this isn't an error and does not drastically affect the code, then it is fine. There are many warnings, let's not start chasing compiler-specific warnings. GCC isn't the only targeted compiler for EX+ and GCC is known to complain about things that aren't even an issue.