build : silence misleading -Warray-bounds warning

There is a -Warray-bounds warning from g++ 13.2.1 in
test-llama-grammar.cpp that is a false-positive because there is a
ternary that special-cases zero in the std::vector code.

/usr/include/c++/13.2.1/bits/stl_algobase.h:398:17: warning: array subscript 0 is outside array bounds of ‘const llama_grammar_element* [0]’ [-Warray-bounds=]
  398 |         { *__to = *__from; }
      |           ~~~~~~^~~~~~~~~
This commit is contained in:
Cebtenzzre 2023-09-05 18:27:14 -04:00
parent 9e2023156e
commit ceee3a6c22
2 changed files with 2 additions and 2 deletions

View file

@ -423,7 +423,7 @@ if (LLAMA_ALL_WARNINGS)
) )
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# g++ only # g++ only
set(cxx_flags ${cxx_flags} -Wno-format-truncation) set(cxx_flags ${cxx_flags} -Wno-format-truncation -Wno-array-bounds)
endif() endif()
else() else()
# todo : msvc # todo : msvc

View file

@ -123,7 +123,7 @@ MK_CXXFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-m
ifeq '' '$(findstring clang++,$(CXX))' ifeq '' '$(findstring clang++,$(CXX))'
# g++ only # g++ only
MK_CXXFLAGS += -Wno-format-truncation MK_CXXFLAGS += -Wno-format-truncation -Wno-array-bounds
endif endif
# OS specific # OS specific