atsb / Doom64EX-Plus

An improved modern version of Doom64EX.
GNU General Public License v2.0
100 stars 16 forks source link

GCC 13 overflow warning in p_user.c #227

Open bubbleguuum opened 4 months ago

bubbleguuum commented 4 months ago

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.

Wolf3s commented 4 months ago

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.

bubbleguuum commented 4 months ago

The trace above was because I was compiling with -Werror (which makes all warnings to be error). Without -Werror above message is a warning.

Wolf3s commented 4 months ago

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.

Wolf3s commented 4 months ago

Nowadays i go carefully about warnings since some of them can be a false alarme to broke the code.

bubbleguuum commented 4 months ago

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.

Wolf3s commented 4 months ago

Author

i´ve made a review on your pull request, about __compar_fn_t

Wolf3s commented 4 months ago

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.

Unsigned char?