Grumbel / sdl-jstest

Simple SDL joystick test application for the console
GNU General Public License v3.0
55 stars 31 forks source link

warning: result of comparison of constant with expression of type 'int' is always false #16

Closed orbea closed 1 year ago

orbea commented 1 year ago

OS: Gentoo sdl-jstest: https://github.com/Grumbel/sdl-jstest/commit/62124aa8b9d4c3a8eec5206bf0fc09fade52b326 clang: 16.0.6

With clang it prints a few -Wtautological-constant-out-of-range-compare warnings that seem somewhat concerning.

[1/4] /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-clang -DSDL2_JSTEST_DATADIR=\"/usr/share/sdl-jstest\" -DSDL_JSTEST_VERSION=\"0.2.2-1-g62124aa\" -isystem /usr/include/SDL2 -isystem /usr/include/ncursesw  -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -std=c99 -D_REENTRANT -DNCURSES_WIDECHAR -MD -MT CMakeFiles/sdl2-jstest.dir/src/sdl2-jstest.c.o -MF CMakeFiles/sdl2-jstest.dir/src/sdl2-jstest.c.o.d -o CMakeFiles/sdl2-jstest.dir/src/sdl2-jstest.c.o -c /var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl2-jstest.c
[2/4] /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-clang -DSDL_JSTEST_VERSION=\"0.2.2-1-g62124aa\" -isystem /usr/include/SDL -isystem /usr/include/ncursesw  -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -std=c99 -DNCURSES_WIDECHAR -MD -MT CMakeFiles/sdl-jstest.dir/src/sdl-jstest.c.o -MF CMakeFiles/sdl-jstest.dir/src/sdl-jstest.c.o.d -o CMakeFiles/sdl-jstest.dir/src/sdl-jstest.c.o -c /var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl-jstest.c
/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl-jstest.c:53:53: warning: result of comparison of constant -9223372036854775808 with expression of type 'int' is always false [-Wtautological-constant-out-of-range-compare]
  if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN))
                                               ~~~~ ^  ~~~~~~~~
/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl-jstest.c:53:33: warning: result of comparison of constant 9223372036854775807 with expression of type 'int' is always false [-Wtautological-constant-out-of-range-compare]
  if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN))
                           ~~~~ ^  ~~~~~~~~
2 warnings generated.
[3/4] : && /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-clang -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -std=c99 -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--as-needed    -rdynamic CMakeFiles/sdl-jstest.dir/src/sdl-jstest.c.o -o sdl-jstest  -Wl,-Bstatic  -lSDLmain  -Wl,-Bdynamic  -lSDL  -lncursesw  -ltinfow && :
/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl2-jstest.c:46:53: warning: result of comparison of constant -9223372036854775808 with expression of type 'int' is always false [-Wtautological-constant-out-of-range-compare]
  if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN))
                                               ~~~~ ^  ~~~~~~~~
/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl2-jstest.c:46:33: warning: result of comparison of constant 9223372036854775807 with expression of type 'int' is always false [-Wtautological-constant-out-of-range-compare]
  if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN))
                           ~~~~ ^  ~~~~~~~~
2 warnings generated.
[4/4] : && /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-clang -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -std=c99 -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--as-needed    -rdynamic CMakeFiles/sdl2-jstest.dir/src/sdl2-jstest.c.o -o sdl2-jstest  -lSDL2  -lncursesw  -ltinfow && :