Doom64EX-Plus icon indicating copy to clipboard operation
Doom64EX-Plus copied to clipboard

GCC 13 overflow warning in p_user.c

Open bubbleguuum opened this issue 1 year ago • 7 comments

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.

bubbleguuum avatar Jan 14 '24 19:01 bubbleguuum

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.

Wolf3s avatar Jan 14 '24 21:01 Wolf3s

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

bubbleguuum avatar Jan 14 '24 21:01 bubbleguuum

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 avatar Jan 14 '24 21:01 Wolf3s

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

Wolf3s avatar Jan 14 '24 21:01 Wolf3s

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.

bubbleguuum avatar Jan 14 '24 22:01 bubbleguuum

Author

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

Wolf3s avatar Jan 14 '24 22:01 Wolf3s

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?

Wolf3s avatar Jan 16 '24 15:01 Wolf3s

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.

atsb avatar Jul 25 '24 08:07 atsb