From e4743e3186739a89c81977939437f4fb9772e5e8 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 25 Apr 2025 20:02:57 +0200 Subject: [PATCH] Disable -Warray-bounds due to GCC bug To avoid getting warnings like: In file included from ../../../extern/sol3/sol/compatibility.hpp:46, from ../../../extern/sol3/sol/bytecode.hpp:27, from ../../../extern/sol3/sol/sol.hpp:51, from ../../../components/lua/luastate.hpp:8, from ../../../apps/openmw/mwlua/context.hpp:4, from ../../../apps/openmw/mwlua/soundbindings.hpp:6, from ../../../apps/openmw/mwlua/soundbindings.cpp:1: In member function 'void sol::stack::field_getter >::get(lua_State*, Key&&, int) [with Key = const char (&)[7]; T = char [7]; bool global = false; bool raw = false; = void]', inlined from 'void sol::stack::get_field(lua_State*, Key&&, int) [with bool global = false; bool raw = false; Key = const char (&)[7]]' at ../../../extern/sol3/sol/stack_core.hpp:1210:62, inlined from 'sol::stack::probe sol::stack::probe_field_getter >::get(lua_State*, Key&&, int) [with Key = const char (&)[7]; T = char [7]; P = float; bool b = false; bool raw = false; = void]' at ../../../extern/sol3/sol/stack_probe.hpp:41:21, inlined from 'sol::stack::probe sol::stack::probe_field_getter >::get(lua_State*, Key&&, int) [with Key = const char (&)[6]; T = char [6]; P = float; bool b = false; bool raw = false; = void]' at ../../../extern/sol3/sol/stack_probe.hpp:35:9, inlined from 'sol::stack::probe sol::stack::probe_get_field(lua_State*, Key&&, int) [with bool global = false; bool raw = false; C = float; Key = const char (&)[6]]' at ../../../extern/sol3/sol/stack_core.hpp:1230:78, inlined from 'decltype(auto) sol::basic_table_core<, >::traverse_get_deep_optional(int&, int, Key&&, Keys&& ...) const [with bool global = false; bool raw = false; sol::detail::insert_mode mode = sol::detail::none; T = sol::optional; Key = const char (&)[6]; Keys = {}; bool top_level = false; ref_t = sol::basic_reference]' at ../../../extern/sol3/sol/table_core.hpp:217:62, inlined from 'decltype(auto) sol::basic_table_core<, >::traverse_get_single(int, Keys&& ...) const [with bool raw = false; Ret = sol::optional; Keys = {const char (&)[6]}; bool top_level = false; ref_t = sol::basic_reference]' at ../../../extern/sol3/sol/table_core.hpp:123:83, inlined from 'decltype(auto) sol::basic_table_core<, >::traverse_get_single_maybe_tuple(int, Key&&) const [with bool raw = false; Ret = sol::optional; Key = const char (&)[6]; bool top_level = false; ref_t = sol::basic_reference]' at ../../../extern/sol3/sol/table_core.hpp:113:41, inlined from 'decltype(auto) sol::basic_table_core<, >::tuple_get(int, Keys&& ...) const [with bool raw = false; Ret = {sol::optional}; Keys = {const char (&)[6]}; bool top_level = false; ref_t = sol::basic_reference]' at ../../../extern/sol3/sol/table_core.hpp:93:56, inlined from 'decltype(auto) sol::basic_table_core<, >::get(Keys&& ...) const [with Ret = {sol::optional}; Keys = {const char (&)[6]}; bool top_level = false; ref_t = sol::basic_reference]' at ../../../extern/sol3/sol/table_core.hpp:422:35, inlined from 'decltype(auto) sol::basic_table_core<, >::get_or(Key&&, T&&) const [with T = float; Key = const char (&)[6]; bool top_level = false; ref_t = sol::basic_reference]' at ../../../extern/sol3/sol/table_core.hpp:428:41, inlined from '{anonymous}::PlaySoundArgs {anonymous}::getPlaySoundArgs(const sol::optional > >&)' at ../../../apps/openmw/mwlua/soundbindings.cpp:62:42: ../../../extern/sol3/sol/stack_field.hpp:116:49: error: array subscript 'const char [7][0]' is partly outside array bounds of 'const char [6]' [-Werror=array-bounds=] 116 | lua_getfield(L, tableindex, &key[0]); | ^~~~~~~~~~~~ Simplified example: https://godbolt.org/z/ccPje4nK1 --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94b52e0156..bd66eb2c48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -594,6 +594,11 @@ endif() if (CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) set(OPENMW_CXX_FLAGS "-Wall -Wextra -Wundef -Wextra-semi -Wno-unused-parameter -pedantic -Wno-long-long -Wnon-virtual-dtor -Wunused ${OPENMW_CXX_FLAGS}") + if (CMAKE_CXX_COMPILER_ID STREQUAL GNU) + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105438 + set(OPENMW_CXX_FLAGS "-Wno-array-bounds ${OPENMW_CXX_FLAGS}") + endif() + if (APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")