Skip to content

-Warray-bounds build warning

[83/134] Building C object src/CMakeFiles/SRB2SDL2.dir/lua_hooklib.c.o
In function ‘add_string_hook’,
    inlined from ‘lib_addHook’ at [...]/src/lua_hooklib.c:214:3,
    inlined from ‘lib_addHook’ at [...]/src/lua_hooklib.c:200:12:
[...]/src/lua_hooklib.c:120:43: warning: array subscript -1 is below array bounds of ‘stringhook_t[3]’ [-Warray-bounds=]
  120 |         stringhook_t * hook = &stringHooks[type];
      |                                ~~~~~~~~~~~^~~~~~
[...]/src/lua_hooklib.c: In function ‘lib_addHook’:
[...]/src/lua_hooklib.c:59:21: note: while referencing ‘stringHooks’
   59 | static stringhook_t stringHooks[STRING_HOOK(MAX)];
      |                     ^~~~~~~~~~~
[134/134] Linking CXX executable bin/lsdlsrb2_next

Compiled through CMake, GCC version is gcc version 13.2.1 20230801 (GCC)

Edited by Lactozilla