From eb2749ee51133f86242fd91d99ddbba5bd6b2956 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Fri, 23 Aug 2024 11:34:13 -0400 Subject: [PATCH] [test] Suppress a bogus warning on GCC 11.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC warns, even though this entire loop is guarded by `n <= size_` and we humans know that `size_ <= N`. In file SG14/test/aa_inplace_vector_smallsize_test.cpp:3: SG14/include/sg14/aa_inplace_vector.h: In member function ‘virtual void aa_inplace_vector_smallsize_ConstructorsThrow_Test::TestBody()’: SG14/include/sg14/aa_inplace_vector.h:635:28: error: iteration 3 invokes undefined behavior [-Werror=aggressive-loop-optimizations] 635 | (*this)[i] = value; | ~~~~~~~~~~~^~~~~~~ SG14/include/sg14/aa_inplace_vector.h:634:34: note: within this loop 634 | for (size_t i = 0; i < n; ++i) { | ~~^~~ --- test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fec76de..eac74b4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -36,6 +36,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set_property(TARGET utest APPEND PROPERTY COMPILE_OPTIONS "-Wall;-Wextra;-Werror") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set_property(TARGET utest APPEND PROPERTY COMPILE_OPTIONS "-Wall;-Wextra;-Werror") + # GCC 11 gives bogus warning "iteration 3 invokes undefined behavior" + set_property(SOURCE aa_inplace_vector_smallsize_test.cpp APPEND PROPERTY COMPILE_OPTIONS "-Wno-aggressive-loop-optimizations") # GCC 13 gives bogus warnings on local types with typedefs set_property(SOURCE hive_test.cpp APPEND PROPERTY COMPILE_OPTIONS "-Wno-unused-local-typedefs") if (CMAKE_CXX_COMPILER_VERSION MATCHES "^7.*")