1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 14:11:33 +00:00

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<T, global, raw, <template-parameter-1-4> >::get(lua_State*, Key&&, int) [with Key = const char (&)[7]; T = char [7]; bool global = false; bool raw = false; <template-parameter-1-4> = 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<T, P, global, raw, <template-parameter-1-5> >::get(lua_State*, Key&&, int) [with Key = const char (&)[7]; T = char [7]; P = float; bool b = false; bool raw = false; <template-parameter-1-5> = void]' at ../../../extern/sol3/sol/stack_probe.hpp:41:21,
    inlined from 'sol::stack::probe sol::stack::probe_field_getter<T, P, global, raw, <template-parameter-1-5> >::get(lua_State*, Key&&, int) [with Key = const char (&)[6]; T = char [6]; P = float; bool b = false; bool raw = false; <template-parameter-1-5> = 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<<anonymous>, <template-parameter-1-2> >::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<float>; Key = const char (&)[6]; Keys = {}; bool top_level = false; ref_t = sol::basic_reference<false>]' at ../../../extern/sol3/sol/table_core.hpp:217:62,
    inlined from 'decltype(auto) sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::traverse_get_single(int, Keys&& ...) const [with bool raw = false; Ret = sol::optional<float>; Keys = {const char (&)[6]}; bool top_level = false; ref_t = sol::basic_reference<false>]' at ../../../extern/sol3/sol/table_core.hpp:123:83,
    inlined from 'decltype(auto) sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::traverse_get_single_maybe_tuple(int, Key&&) const [with bool raw = false; Ret = sol::optional<float>; Key = const char (&)[6]; bool top_level = false; ref_t = sol::basic_reference<false>]' at ../../../extern/sol3/sol/table_core.hpp:113:41,
    inlined from 'decltype(auto) sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::tuple_get(int, Keys&& ...) const [with bool raw = false; Ret = {sol::optional<float>}; Keys = {const char (&)[6]}; bool top_level = false; ref_t = sol::basic_reference<false>]' at ../../../extern/sol3/sol/table_core.hpp:93:56,
    inlined from 'decltype(auto) sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::get(Keys&& ...) const [with Ret = {sol::optional<float>}; Keys = {const char (&)[6]}; bool top_level = false; ref_t = sol::basic_reference<false>]' at ../../../extern/sol3/sol/table_core.hpp:422:35,
    inlined from 'decltype(auto) sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::get_or(Key&&, T&&) const [with T = float; Key = const char (&)[6]; bool top_level = false; ref_t = sol::basic_reference<false>]' at ../../../extern/sol3/sol/table_core.hpp:428:41,
    inlined from '{anonymous}::PlaySoundArgs {anonymous}::getPlaySoundArgs(const sol::optional<sol::basic_table_core<false, sol::basic_reference<false> > >&)' 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
This commit is contained in:
elsid 2025-04-25 20:02:57 +02:00
parent 7cef010bfe
commit e4743e3186
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40

View file

@ -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++")