Skip to content

Commit

Permalink
[test] Suppress a bogus warning on GCC 11.4
Browse files Browse the repository at this point in the history
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) {
          |                                ~~^~~
  • Loading branch information
Quuxplusone committed Aug 23, 2024
1 parent fc6532f commit 127c701
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*")
Expand Down

0 comments on commit 127c701

Please sign in to comment.