Skip to content

Commit

Permalink
slot_map : Fix gcc7 structured bindings warnings.
Browse files Browse the repository at this point in the history
Gcc7 doesn't implement [[maybe_unused]] attribute for structured
bindings. Disable unused-parameter checks on gcc7 (only).

slot_map.h:48:91: error: unused variable ¿gen¿ [-Werror=unused-variable]
     static constexpr auto get_index(const Key& k) { [[maybe_unused]] const auto& [idx, gen] = k; return idx; }

Also disable buggy unused-but-set-variable for gcc7 (only).

error: variable ¿idx¿ set but not used [-Werror=unused-but-set-variable]
  template<class Integral> static constexpr void set_index(Key& k, Integral value) { auto&[idx, gen] = k; detail::maybe_unused(gen); idx = static_cast<key_size_type>(value); }
  • Loading branch information
Philippe Groarke committed Dec 1, 2018
1 parent ed4cf4e commit f2b8e80
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set_source_files_properties(${SG14_TEST_SOURCE_DIRECTORY}/plf_colony_test.cpp PROPERTIES
COMPILE_FLAGS "-Wno-unused-parameter"
)
if (CMAKE_CXX_COMPILER_VERSION MATCHES "^7.*")
set_source_files_properties(${SG14_TEST_SOURCE_DIRECTORY}/slot_map_test.cpp PROPERTIES
COMPILE_FLAGS "-Wno-error=unused-variable -Wno-error=unused-but-set-variable") # Fix gcc7 issues with structured bindings
message("Disabled -Wunused-variable and -Wunused-but-set-variable for gcc ${CMAKE_CXX_COMPILER_VERSION}.")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TEST_NAME})
target_compile_options(${TEST_NAME} PRIVATE /Zc:__cplusplus /permissive- /W4 /WX)
Expand Down

0 comments on commit f2b8e80

Please sign in to comment.