From 34448476f4b08914669767ec55b08e94957c630f Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Mon, 29 Apr 2024 18:00:33 +0200 Subject: [PATCH] Fix GCC/CMake warnings for Noble (#2375) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use latest 1.14 google-test in gtest_setup Signed-off-by: Jose Luis Rivero * Make gcc happy about dangling pointer GCC is emitting a warning about a possible danling pointer on table like definitions: warning: possibly dangling reference to a temporary [-Wdangling-reference] 660 | auto const& table = get_current_events_table(state_indexes{}); | ^~~~~ Which I think that really comes from the use of state_indexes{} as argument: note: the temporary was destroyed at the end of the full expression 660 | auto const& table = get_current_events_table(state_indexes{}); | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ Clang is quiet about this and make me think that is a false positive since the metaprogramming code is using just the type of the state_indexes as much as I can see. --------- Signed-off-by: Jose Luis Rivero Co-authored-by: Alejandro Hernández Cordero --- .../plugin/custom_sensor_system/CMakeLists.txt | 9 +++++---- examples/standalone/gtest_setup/CMakeLists.txt | 3 ++- .../afsm/include/afsm/detail/transitions.hpp | 17 +++++++++++------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/examples/plugin/custom_sensor_system/CMakeLists.txt b/examples/plugin/custom_sensor_system/CMakeLists.txt index 32bb92dac3..09abde0f62 100644 --- a/examples/plugin/custom_sensor_system/CMakeLists.txt +++ b/examples/plugin/custom_sensor_system/CMakeLists.txt @@ -27,10 +27,11 @@ add_subdirectory(${sensors_clone_SOURCE_DIR}/examples/custom_sensor ${sensors_cl add_library(${PROJECT_NAME} SHARED ${PROJECT_NAME}.cc) target_link_libraries(${PROJECT_NAME} - PRIVATE gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER} - PRIVATE gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER} - PRIVATE gz-sensors${GZ_SENSORS_VER}::gz-sensors${GZ_SENSORS_VER} - PRIVATE odometer + PRIVATE + gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER} + gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER} + gz-sensors${GZ_SENSORS_VER}::gz-sensors${GZ_SENSORS_VER} + odometer ) target_include_directories(${PROJECT_NAME} PUBLIC ${sensors_clone_SOURCE_DIR}/examples/custom_sensor) diff --git a/examples/standalone/gtest_setup/CMakeLists.txt b/examples/standalone/gtest_setup/CMakeLists.txt index 376497eeaf..ee03ecce4c 100644 --- a/examples/standalone/gtest_setup/CMakeLists.txt +++ b/examples/standalone/gtest_setup/CMakeLists.txt @@ -10,7 +10,8 @@ set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR}) include(FetchContent) FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip + # Version 1.14. Use commit hash to prevent tag relocation + URL https://github.com/google/googletest/archive/f8d7d77c06936315286eb55f8de22cd23c188571.zip ) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) diff --git a/src/systems/elevator/vender/afsm/include/afsm/detail/transitions.hpp b/src/systems/elevator/vender/afsm/include/afsm/detail/transitions.hpp index e4fe1fa821..7b5843c009 100644 --- a/src/systems/elevator/vender/afsm/include/afsm/detail/transitions.hpp +++ b/src/systems/elevator/vender/afsm/include/afsm/detail/transitions.hpp @@ -525,7 +525,8 @@ class state_transition_table { void check_default_transition() { - auto const& ttable = transition_table( state_indexes{} ); + auto st = state_indexes{}; + auto const& ttable = transition_table(st); ttable[current_state()](*this, none{}); } @@ -544,7 +545,8 @@ class state_transition_table { void exit(Event&& event) { - auto const& table = exit_table( state_indexes{} ); + auto st = state_indexes{}; + auto const& table = exit_table(st); table[current_state()](states_, ::std::forward(event), *fsm_); } @@ -552,7 +554,8 @@ class state_transition_table { actions::event_process_result process_transition_event(Event&& event) { - auto const& inv_table = transition_table( state_indexes{} ); + auto st = state_indexes{}; + auto const& inv_table = transition_table(st); return inv_table[current_state()](*this, ::std::forward(event)); } @@ -655,10 +658,11 @@ class state_transition_table { event_set current_handled_events() const { - auto const& table = get_current_events_table(state_indexes{}); + auto st = state_indexes{}; + auto const& table = get_current_events_table(st); auto res = table[current_state_](states_); auto const& available_transitions - = get_available_transitions_table(state_indexes{}); + = get_available_transitions_table(st); auto const& trans = available_transitions[current_state_]; res.insert( trans.begin(), trans.end()); return res; @@ -667,7 +671,8 @@ class state_transition_table { event_set current_deferrable_events() const { - auto const& table = get_current_deferred_events_table(state_indexes{}); + auto st = state_indexes{}; + auto const& table = get_current_deferred_events_table(st); return table[current_state_](states_); }